コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $staff = new Staff();
     $staff->fill($request->all());
     $slug = Helpers::makeSlug($request->input('full_name_geo'), 'staff');
     if ($slug == "") {
         return Redirect::route('admin.index');
     }
     $staff->slug = $slug;
     $image = $request->file('image');
     $fileName = "";
     if ($image->isValid()) {
         $path = public_path() . '/uploads/staff/';
         $fileName = str_random(32) . '.' . $image->getClientOriginalExtension();
         $image->move($path, $fileName);
     } else {
         App::abort(404);
     }
     $staff->image = $fileName;
     $staff->save();
     return Redirect::route('admin.staff.show');
 }