Example #1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $item = Item::whereId($id)->first();
     if (empty($item)) {
         return $this->saveResponse(false);
     }
     return $this->saveResponse($item->delete());
 }
 /**
  * Handle the command.
  *
  * @param  UpdateItemCommand  $command
  * @return void
  */
 public function handle(UpdateItemCommand $command)
 {
     $item = Item::whereId($command->id)->first();
     if (!empty($item)) {
         $item->title = $command->title;
         $item->description = $command->description;
         $item->extra_description = $command->description;
         $item->amount = $command->amount;
         $item->switch = (int) $command->switch;
         $item->category_id = $command->category_id;
         if ($item->save()) {
             return $item;
         }
     }
     return false;
 }