Last active
April 11, 2020 06:55
-
-
Save moradi-morteza/cd2cabeff0809c020ded8440b69dc69e to your computer and use it in GitHub Desktop.
[job] #LaravelT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
---in file config queue you should change QUEUE_CONNECTION------> in env QUEUE_CONNECTION=database -------> reset config env in command | |
php artisan queue:table // create a migration for jobs | |
php artisan make:job SendVerificationEmailJob | |
// where you want to do : | |
SendVerificationEmailJob.dispatch($user); | |
// in send verificationEmailJob class | |
private $user; | |
public function __construct (User $user){ | |
$this->user=$user; | |
} | |
public function handle(){ | |
// get user data and do your work | |
send email .... | |
} | |
// to start jobs in artisan : | |
php artisan queue:work | |
// if you close command with ctrl+C then queue stoped! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment