![]() 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/Couriers/ |
<?php namespace App\Shop\Couriers; use Jsdecena\Baserepo\BaseRepository; use App\Shop\Couriers\Courier; use App\Shop\Couriers\Exceptions\CourierInvalidArgumentException; use App\Shop\Couriers\Exceptions\CourierNotFoundException; use App\Shop\Couriers\Repositories\Interfaces\CourierRepositoryInterface; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\QueryException; use Illuminate\Support\Collection; class CourierRepository extends BaseRepository implements CourierRepositoryInterface { /** * CourierRepository constructor. * @param Courier $courier */ public function __construct(Courier $courier) { parent::__construct($courier); $this->model = $courier; } /** * Create the courier * * @param array $params * @return Courier * @throws CourierInvalidArgumentException */ public function createCourier(array $params) : Courier { try { return $this->create($params); } catch (QueryException $e) { throw new CourierInvalidArgumentException($e->getMessage()); } } /** * Update the courier * * @param array $params * * @return bool * @throws CourierInvalidArgumentException */ public function updateCourier(array $params) : bool { try { return $this->update($params); } catch (QueryException $e) { throw new CourierInvalidArgumentException($e->getMessage()); } } /** * Return the courier * * @param int $id * * @return Courier * @throws CourierNotFoundException */ public function findCourierById(int $id) : Courier { try { return $this->findOneOrFail($id); } catch (ModelNotFoundException $e) { throw new CourierNotFoundException('Courier not found.'); } } /** * Return all the couriers * * @param string $order * @param string $sort * @return Collection|mixed */ public function listCouriers(string $order = 'id', string $sort = 'desc') : Collection { return $this->all(['*'], $order, $sort); } /** * @return bool * @throws \Exception */ public function deleteCourier() { return $this->delete(); } }