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