/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $category = Category::whereId($id)->first(); if (empty($category)) { return $this->saveResponse(false); } return $this->saveResponse($category->delete()); }
/** * Handle the command. * * @param UpdateCategoryCommand $command * @return void */ public function handle(UpdateCategoryCommand $command) { $category = \App\Models\Category::whereId($command->id)->first(); if (!empty($category)) { $category->title = $command->title; $category->slug = $command->slug; $category->description = $command->description; $category->estimate = $command->estimate; $category->income = $command->income; $category->colour = $command->colour; if ($category->save()) { return $category; } } return false; }