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(); } }