Created
May 22, 2018 18:04
-
-
Save DarkGhostHunter/a1ecd443adf1e19ca66082509f6e9ae0 to your computer and use it in GitHub Desktop.
56413a512688-ProcessNewUser
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 | |
namespace App\Jobs; | |
use App\User; | |
use App\UserVisit; | |
use App\Accounting; | |
use App\Notifications\UserGreetingEmail; | |
use Illuminate\Bus\Queueable; | |
use Illuminate\Queue\SerializesModels; | |
use Illuminate\Queue\InteractsWithQueue; | |
use Illuminate\Contracts\Queue\ShouldQueue; | |
use Illuminate\Foundation\Bus\Dispatchable; | |
class ProcessNewUser implements ShouldQueue | |
{ | |
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | |
/** | |
* @var User $user | |
*/ | |
protected $user; | |
/** | |
* Create a new job instance. | |
* | |
* @param User $user | |
* @return void | |
*/ | |
public function __construct(User $user) | |
{ | |
$this->user = $user; | |
} | |
/** | |
* Execute the job. | |
* | |
* @return void | |
*/ | |
public function handle() | |
{ | |
/* Send an email */ | |
$this->user->notify(new UserGreetingEmail($user)); | |
/* Calculate the meaning of life, no kidding */ | |
MeaningOfLife::create(43); | |
/* Save the user on our list of scheduled visits */ | |
UserVisit::create([ | |
'user_id' => $this->user->id, | |
'visit_before' => today()->next(5), | |
]); | |
/* Add to the Accounting table the new user to bill */ | |
Accounting::create([ | |
'user_id' => $this->user->id, | |
'last_billed_at' => null, | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment