-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathSendEmailJobs.php
44 lines (40 loc) · 1.12 KB
/
SendEmailJobs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace App\Jobs;
use App\Mail\AdminAlertMail;
use App\Models\Admin;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Storage;
class SendEmailJobs implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $loggedInAdmin;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($loggedInAdmin)
{
$this->loggedInAdmin = $loggedInAdmin;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
if($this->loggedInAdmin->is_super != 1){
$superAdmins = Admin::where('is_super',1)->get();
foreach ($superAdmins as $to) {
Mail::to($to->email)->send(new AdminAlertMail($this->loggedInAdmin));
Storage::disk('public')->put('log.json',`Logged In Admin: `.$to->email);
}
}
}
}