/** * Attempts to get a customer from a given ID. * * @param int $id Customer ID. * * @return Model_Customer */ protected function get_customer($id) { if (!$id) { throw new HttpNotFoundException(); } $customer = Service_Customer::find_one(array('id' => $id, 'status' => 'all')); if (!$customer || $customer->seller != Seller::active()) { throw new HttpNotFoundException(); } return $customer; }
/** * Attempts to get a customer from a given ID. * * @param int $id Customer ID. * * @return \Model_Customer */ protected function get_customer($id) { if (!$id) { throw new HttpNotFoundException(); } $customer = \Service_Customer::find_one($id); if (!$customer || $customer->seller != \Seller::active()) { throw new HttpNotFoundException(); } return $customer; }
/** * Gets one or more customer product options. * * @param int $customer_id Customer ID. * @param int $id Product option ID. * * @return void */ public function get_index($customer_id = null, $id = null) { if (!$customer_id) { throw new HttpNotFoundException(); } $customer = \Service_Customer::find_one($customer_id); if (!$customer || $customer->seller != \Seller::active()) { throw new HttpNotFoundException(); } if (!$id) { $products = \Service_Customer_Product_Option::find(array('customer' => $customer)); } else { $products = \Service_Customer_Product_Option::find_one($id); if (!$products || $products->customer != $customer) { throw new HttpNotFoundException(); } } $this->response($products); }