/** * Take the booth. * * @param Request $request * @param Booth $booth * @return Response */ public function takeBooth(Request $request, Booth $booth) { $booth->user_id = $request->user()->id; $booth->save(); return redirect('/booths'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // $v = Validator::make(Request::all(), ['name' => 'required|max:50|unique:halls', 'type_id' => 'required', 'modeldesign_id' => 'required', 'exhibitor' => 'required', 'exhibitionevent' => 'required']); if ($v->fails()) { return redirect()->back()->withErrors($v->errors())->withInput(); } else { $booth = new Booth(); $booth->name = Request::get('name'); $booth->desc = Request::get('desc'); $booth->type_id = Request::get('type_id'); $booth->modeldesign_id = Request::get('modeldesign_id'); $booth->exhibitor_id = Request::get('exhibitor'); $booth->exhibition_event_id = Request::get('exhibitionevent'); $booth->spot_id = Request::get('spot_id'); $booth->save(); // File Storage $file = new File(); $file->name = Request::get('filename'); $file->desc = Request::get('filedesc'); $file->type = Request::get('filetype'); if (Request::hasFile('file')) { $destination = 'files/'; $filename = str_random(6) . "_" . Request::file('file')->getClientOriginalName(); Request::file('file')->move($destination, $filename); $file->file = $filename; } else { $file->file = Request::get('file'); } $file->save(); $boothfile = new BoothFile(); $boothfile->booth_id = $booth->id; $boothfile->file_id = $file->id; $boothfile->save(); return redirect('booths'); } }