Hey @tam1,
So I followed your advice but it seems that nothing is happening, I created a store function and Job class, and when I run smaller things like 20 entries it finishes and I get an email.. But if I just pass (like just to count entries and send back to email) it never sends the email, and after uploading the file it just returns blank post route, here is the code:
public function queueOldUsers(Request $request)
{
if($request->hasFile('oldOnes')) {
$path = $request->file('oldOnes')->path();
$this->dispatch(new ImportOldContacts($path));
}
}
class ImportOldContacts implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
protected $file;
/**
* ImportOldContacts constructor.
* @param $file
*/
public function __construct($file)
{
$this->file = $file;
}
/**
* @param \Maatwebsite\Excel\Excel $excel
* @param \App\ImportMail $mailer
*/
public function handle(Excel $excel, ImportMail $mailer)
{
$load = $excel->load($this->file, function($reader) {})->get();
$data = 0;
foreach($load as $row) {
$data++;
}
$mailer->importIsDone($data);
}
}
This is my model that sends the email
class ImportMail extends Model
{
public static function agileIsDone($data) {
if(Auth::check()) {
$receiver = "[email protected]";
Mail::send('emails.notifications.import', ['data' => $data], function ($m) use ($receiver) {
$m->from('[email protected]', 'import test!');
$m->to($receiver)->subject('Testing Import!');
});
}
}
}
So as I've said when it's smaller file it goes well, but when it is like 70.000, and again I'm just trying for now to "count" them trough foreach to see if it goes trough the entire file, but I never got the email...
Help?