Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mcoil.corals.io/app/Shop/Businesses/Repositories/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mcoil.corals.io/app/Shop/Businesses/Repositories/BusinessRepository.php
<?php

namespace App\Shop\Businesses\Repositories;

use Jsdecena\Baserepo\BaseRepository;
use App\Shop\Businesses\Exceptions\BusinessInvalidArgumentException;
use App\Shop\Businesses\Exceptions\BusinessNotFoundException;
use App\Shop\Businesses\Repositories\Interfaces\BusinessRepositoryInterface;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Database\QueryException;
use App\Shop\Businesses\Business;
use Illuminate\Support\Collection;

class BusinessRepository extends BaseRepository implements BusinessRepositoryInterface
{
    /**
     * BusinessRepository constructor.
     * @param Business $business
     */
    public function __construct(Business $business)
    {
        parent::__construct($business);
        $this->model = $business;
    }

    /**
     * List all the Businesses
     *
     * @param string $order
     * @param string $sort
     * @param array $except
     * @return \Illuminate\Support\Collection
     */
    public function listBusinesses(string $order = 'id', string $sort = 'desc', $except = []) : Collection
    {
        return $this->model->orderBy($order, $sort)->get()->except($except);
    }

    /**
     * @param string $text
     * @return mixed
     */
    public function searchBusiness(string $text = null) : Collection
    {
        if (is_null($text)) {
            return $this->all();
        }
        return $this->model->searchBusiness($text)->get();
    }

    /**
     * @param array $params
     * @return Business
     */
    public function createBusiness(array $params) : Business
    {
        return $this->create($params);
    }

    /**
     * Find the business
     *
     * @param $id
     * @return Business
     * @throws BusinessNotFoundException
     */
    public function findBusinessById(int $id) : Business
    {
        try {
            return $this->findOneOrFail($id);
        } catch (ModelNotFoundException $e) {
            throw new BusinessNotFoundException('Business not found.');
        }
    }

    /**
     * Update the business
     *
     * @param array $params
     *
     * @return Business
     * @throws BusinessNotFoundException
     */
    public function updateBusiness(array $params) : Business
    {
        try {
            $this->model->update($params);
            return $this->findBusinessById($this->model->id);
        } catch (QueryException $e) {
            throw new BusinessInvalidArgumentException($e->getMessage());
        }
    }

    public function searchBusinessesWithParameters(string $text = null, array $filters = []) : Collection
    {

        $search = $this->model->with('rrp')->where('title','like', "%{$text}%");

        $search = $search->get();
        return $search;
    }

}

Spamworldpro Mini