I am trying to import excel file to db using maatiswebsite. For that I am using queue because it would take some time to import file. I want to show user a quick message that "your file is being imported. we will inform you once it is done." But not able to do it.
QUEUE_DRIVER = database
Here is what I did so far -
Controller -
public function import(Request $request)
{
Excel::filter('chunk')->load($request->file('import_file')
->getRealPath())->chunk(250, function($reader)
{
ImportDistributor::dispatch(new ImportDistributor($reader->toArray()));
});
dd('your file is being imported. we will inform you once it is done.');
}
Job -
public function handle()
{
if(isset($this->data) && !empty($this->data))
{
foreach($this->data as $data)
{
DB::table('user_details')->insert($data);
}
}
}
Model -
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class UserDetailsModel extends Model
{
protected $table = 'user_details';
}
I am not able to store data in user_details.