public static function delete($id) { try { $query = Model_Photo::find($id); $query->delete(); } catch (Exception $e) { Log::write('ERROR', $e->getMessage()); return false; } return true; }
public function post_delete_sub_photo() { $val = Validation::forge(); $val->add_callable('MyRules'); $val->add_field('photo_id', Lang::get('label.photo'), 'required|valid_photo'); $val->add_field('product_id', Lang::get('label.product'), 'required|valid_product'); if ($val->run()) { $photo_id = $val->validated('photo_id'); $photo_name = Model_Photo::find($photo_id)->photo_name; if (Model_Base_Photo::delete($photo_id)) { Model_Service_Upload::delete_photo('photo', $photo_name); $this->data['success'] = true; } } else { $this->data['errors'] = $val->error_message(); } return $this->response($this->data); }