![]() 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/CustomProducts/Repositories/ |
<?php namespace App\Shop\CustomProducts\Repositories; use App\Shop\AttributeValues\AttributeValue; use App\Shop\CustomProducts\CustomProduct; use App\Shop\CustomProducts\Repositories\Interfaces\CustomProductRepositoryInterface; use App\Shop\Products\Exceptions\ProductCreateErrorException; use App\Shop\Products\Exceptions\ProductUpdateErrorException; use App\Shop\Tools\UploadableTrait; use Jsdecena\Baserepo\BaseRepository; use App\Shop\Brands\Brand; use App\Shop\ProductAttributes\ProductAttribute; use App\Shop\ProductImages\ProductImage; use App\Shop\Products\Exceptions\ProductNotFoundException; use App\Shop\Products\Product; use App\Shop\Prices\price; use App\Shop\Products\Repositories\Interfaces\ProductRepositoryInterface; use App\Shop\Products\Transformations\ProductTransformable; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\QueryException; use Illuminate\Http\UploadedFile; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; class CustomProductRepository extends BaseRepository implements CustomProductRepositoryInterface { /** * QuotationRepository constructor. * * @param Quotation $dummy */ public function __construct(CustomProduct $dummy) { parent::__construct($dummy); $this->model = $dummy; } /** * List all the CustomProduct * * @param string $order * @param string $sort * @param array $except * @return \Illuminate\Support\Collection */ public function listCustomProducts(string $order = 'id', string $sort = 'desc', $except = []) : Collection { return $this->model->orderBy($order, $sort)->get()->except($except); } /** * List all the CustomProduct * * @param string $order * @param string $sort * @param array $except * @return \Illuminate\Support\Collection */ public function listCustomProductsWithPagination(string $order = 'id', string $sort = 'desc', $except = []) : Collection { return $this->model->orderBy($order, $sort)->paginate(10)->except($except); } /** * List Trashed the CustomProduct * * @param string $order * @param string $sort * @param array $except * @return \Illuminate\Support\Collection */ public function listCustomProductsTrashedAndPagination(string $order = 'id', string $sort = 'desc', $except = []) : Collection { return $this->model->orderBy($order, $sort)->onlyTrashed()->get()->except($except); } /** * Create Quotation * * @param array $params * * @return CustomProduct * @throws InvalidArgumentException */ public function createCustomProducts(array $params) : CustomProduct { try { return CustomProduct::create($params); } catch (QueryException $e) { throw new InvalidArgumentException($e->getMessage()); } } /** * Update the dummy * * @param array $params * @return CustomProduct */ public function updateCustomProducts(array $params) : CustomProduct { $dummy = $this->findCustomProductsById($this->model->id); $dummy->update($params); return $dummy; } /** * @param int $id * * @return CustomProduct * @throws ModelNotFoundException */ public function findCustomProductsById(int $id) : CustomProduct { try { return $this->findOneOrFail($id); } catch (ModelNotFoundException $e) { throw new ModelNotFoundException($e->getMessage()); } } /** * Delete a dummy * * @return bool * @throws \Exception */ public function deleteCustomProducts() : bool { return $this->model->delete(); } /** * @param string $text * @return mixed */ public function searchCustomProducts(string $text = null) : Collection { if (is_null($text)) { return $this->all(); } return $this->model->searchQuotations($text)->get(); } }