Esempio n. 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), $this->validations);
     $user_id = $request->get('user_id');
     if (!$validator->fails()) {
         $item = Item::find($request->get('item_id'));
         if ($item) {
             if ($item->status == ACTIVE) {
                 $auction = Auction::create($request->except('user_id'));
                 $userAuction = UserAuction::create(['user_id' => $user_id, 'auction_id' => $auction->id]);
                 return view('auctions.index');
             } else {
                 $data['message'] = 'The item you select is not active';
             }
         } else {
             $data['message'] = 'Item not found';
         }
     } else {
         $data['messages'] = $validator->messages();
     }
     return $data;
 }
Esempio n. 2
0
 public function activateItem($item_id)
 {
     $item = Item::find($item_id);
     if ($item) {
         $item->status = 'active';
         $item->save();
         $data = 'Item activated';
     } else {
         $data = 'Item dont found';
     }
     return $data;
 }