![]() 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/OrderStatuses/Repositories/ |
<?php namespace App\Shop\OrderStatuses\Repositories; use Jsdecena\Baserepo\BaseRepository; use App\Shop\OrderStatuses\Exceptions\OrderStatusInvalidArgumentException; use App\Shop\OrderStatuses\Exceptions\OrderStatusNotFoundException; use App\Shop\OrderStatuses\OrderStatus; use App\Shop\OrderStatuses\Repositories\Interfaces\OrderStatusRepositoryInterface; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\QueryException; use Illuminate\Support\Collection; class OrderStatusRepository extends BaseRepository implements OrderStatusRepositoryInterface { /** * OrderStatusRepository constructor. * @param OrderStatus $orderStatus */ public function __construct(OrderStatus $orderStatus) { parent::__construct($orderStatus); $this->model = $orderStatus; } /** * Create the order status * * @param array $params * @return OrderStatus * @throws OrderStatusInvalidArgumentException */ public function createOrderStatus(array $params) : OrderStatus { try { return $this->create($params); } catch (QueryException $e) { throw new OrderStatusInvalidArgumentException($e->getMessage()); } } /** * Update the order status * * @param array $data * * @return bool * @throws OrderStatusInvalidArgumentException */ public function updateOrderStatus(array $data) : bool { try { return $this->update($data); } catch (QueryException $e) { throw new OrderStatusInvalidArgumentException($e->getMessage()); } } /** * @param int $id * @return OrderStatus * @throws OrderStatusNotFoundException */ public function findOrderStatusById(int $id) : OrderStatus { try { return $this->findOneOrFail($id); } catch (ModelNotFoundException $e) { throw new OrderStatusNotFoundException('Order status not found.'); } } /** * @return mixed */ public function listOrderStatuses() { return $this->all(); } /** * @return bool * @throws \Exception */ public function deleteOrderStatus() : bool { return $this->delete(); } /** * @return Collection */ public function findOrders() : Collection { return $this->model->orders()->get(); } /** * @param string $name * * @return mixed */ public function findByName(string $name) { return $this->model->where('name', $name)->first(); } }