Advertisement
OHIDUL951

Controller Method

May 11th, 2016
777
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1.     public function import(Request $request)
  2.     {
  3.         $excel_file = $request->file('excel_file');
  4.         $validator = Validator::make($request->all(), [
  5.             'excel_file' => 'required'
  6.         ]);
  7.  
  8.  
  9.         if($validator->fails()) {
  10.             return Redirect::to('/')->withErrors($validator);
  11.         }
  12.  
  13.         $fname = md5(rand()) . '.csv';
  14.         $full_path = 'files';
  15.         $excel_file->move($full_path, $fname);
  16.         $flag_table = Flag::firstOrNew(['file_name' => $fname]);
  17.         $flag_table->imported = 0;
  18.         $flag_table->save();
  19.  
  20.  
  21.         Artisan::queue('import:excelfile');
  22.      
  23.         return 'File importing is on the way';
  24.  
  25.  
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement