Ejemplo n.º 1
0
 public function createOwl(Requests\CreateOwlRequest $request)
 {
     $characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
     $string = '';
     $random_string_length = 12;
     $name = $request->name;
     for ($i = 0; $i < $random_string_length; $i++) {
         $string .= $characters[rand(0, strlen($characters) - 1)];
     }
     $imageName = $name . '_' . $string . '.' . $request->file('image')->getClientOriginalExtension();
     $owl = new Owl();
     $owl->name = $name;
     $owl->url = $imageName;
     $owl->save();
     $request->file('image')->move(base_path() . '/public/upload/hero/', $imageName);
     Session::flash('success', 'Upload Successful. ');
     return redirect('admin');
 }