Created
May 22, 2018 18:13
-
-
Save DarkGhostHunter/7e8ba08530ac4a794315f2c7f0ffc408 to your computer and use it in GitHub Desktop.
56413a512688-FarewellUser-A
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\UserFarewellEmail; | |
use Illuminate\Bus\Queueable; | |
use Illuminate\Queue\SerializesModels; | |
use Illuminate\Queue\InteractsWithQueue; | |
use Illuminate\Contracts\Queue\ShouldQueue; | |
use Illuminate\Foundation\Bus\Dispatchable; | |
class FarewellUser 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 UserFarewellEmail($user)); | |
/* Delete the Visit */ | |
UserVisit::where('user_id', $this->user->id)->delete(); | |
/* Delete the accounting message */ | |
Accounting::where('user_id', $this->user->id)->delete(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment