示例#1
0
 public function store(Request $request)
 {
     $file = $request->file('file');
     $fileName = $request->input('file_name');
     $fileName = $fileName ?: $file->getClientOriginalName();
     $bulk = Bulk::create(['file_name' => $fileName]);
     if ($file->getClientMimeType() != "text/csv" && $file->getClientOriginalExtension() != "csv") {
         $bulk->result = "Invalid File Type";
         $bulk->mime_type = $file->getClientMimeType();
         $bulk->file_extension = $file->getClientOriginalExtension();
         $bulk->save();
         Flash::error('File type invalid.  Please use a CSV file format.');
         return redirect()->back();
     }
     $csvFile = new CsvFile($file);
     foreach ($csvFile as $row) {
         $indexArray[] = $row;
     }
     for ($i = 0; $i < count($indexArray); $i++) {
         $eraserArray[$i]['MAC'] = $indexArray[$i][0];
         $eraserArray[$i]['TLE'] = $indexArray[$i][1];
         $eraserArray[$i]['BULK_ID'] = $bulk->id;
     }
     $this->dispatch(new EraseTrustList($eraserArray));
     $bulk->result = "Processed";
     $bulk->mime_type = $file->getClientMimeType();
     $bulk->file_extension = $file->getClientOriginalExtension();
     $bulk->process_id = $fileName . '-' . Carbon::now()->timestamp;
     $bulk->save();
     $file->move(storage_path() . '/uploaded_files/', $fileName);
     Flash::success("File loaded successfully!  Check the Bulk Process table for progress on {$bulk->process_id}.");
     $bulks = Bulk::all();
     return view('bulk.index', compact('bulks'));
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->bind('phone', function ($mac) {
         return \App\Phone::where('mac', $mac)->first();
     });
     $router->bind('bulk', function ($process_id) {
         return \App\Bulk::where('process_id', $process_id)->first();
     });
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->bind('phone', function ($mac) {
         return \App\Phone::where('mac', $mac)->first();
     });
     $router->bind('bulk', function ($process_id) {
         return \App\Bulk::where('process_id', $process_id)->first();
     });
     $router->bind('cluster', function ($id) {
         return \App\Cluster::where('id', $id)->first();
     });
     $router->bind('user', function ($name) {
         return \App\User::where('name', $name)->first();
     });
     $router->bind('sql', function ($id) {
         return \App\Sql::where('id', $id)->first();
     });
 }