public function action_create() { if (Auth::is_admin_signed_in() === true) { $view = View::factory('acp/create/product'); $categories = new Model_Category(); $view->categories = $categories->get_list_of_categories(); if ($this->request->method() === Request::POST) { $name = $this->request->post('name'); $valute = $this->request->post('valute'); $category = $this->request->post('category'); $description = $this->request->post('description'); $price = $this->request->post('price'); $img_url = $this->request->post('img_url'); $count = $this->request->post('count'); $price = Currency::to_database($price, $valute); if (empty($name) && empty($category) && empty($description) && empty($price)) { throw new Exception("Please do not make empty fields!"); } $products = new Model_Product(); $data = array('image_url' => $img_url, 'name' => $name, 'category' => $category, 'description' => $description, 'price' => $price, 'count' => $count); $create_new_product = $products->create_new_product($data); if (!$create_new_product) { throw new Exception("Error! Please check for DB settings!"); } $this->request->redirect('acp/products'); } $this->template->content = $view->render(); } else { $this->request->redirect('acp'); } }