34 lines
760 B
PHP
34 lines
760 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Mail\notislelong;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class MailController extends Controller
|
|
{
|
|
public function sendEmail()
|
|
{
|
|
|
|
$users = User::where('user_type', 2)
|
|
->get();
|
|
|
|
foreach ($users as $user) {
|
|
$email = $user->email;
|
|
|
|
$mailData = [
|
|
'title' => 'Notis Lelongan Gadaian',
|
|
'url' => 'https://www.positronx.io', // show unpaid gadaian
|
|
];
|
|
|
|
Mail::to($email)->send(new notislelong($mailData));
|
|
}
|
|
|
|
return response()->json([
|
|
'message' => 'Email has been sent.',
|
|
], Response::HTTP_OK);
|
|
}
|
|
}
|