示例#1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function saveFolder(Request $request)
 {
     //Validate the Request through the validation rules
     $validator = Validator::make($request->all(), ['folder_name' => 'required|min:5']);
     //Take actions when the validation has failed
     if ($validator->fails()) {
         return redirect('create-folder')->withErrors($validator)->withInput();
     }
     $folder = new Folder();
     $folder->name = $request->input('folder_name');
     $folder->created_by = Auth::user()->id;
     $folder->save();
     $folder_path = "folders";
     $folder_path .= "/";
     $folder_path .= Auth::user()->id;
     $folder_path .= "/";
     $folder_path .= $folder->id;
     if (!file_exists($folder_path)) {
         //Create the folder
         mkdir($folder_path, 8777, true);
     }
     return redirect('/');
 }