I have DB like this
|id| email |departement_id|
|1 |test1@gmail.com |1,2 |
|2 |test2@gmail.com |3,4 |
|3 |test3@gmail.com |5,1 |
|4 |test4@gmail.com |2,6 |
I trying to get id
data for send email, from departement_id
. If from request POST departement_id
is 2, so the id
must 1 and 4. How can I get the id in Laravel? because the data in single column-departement_id
-is array.
this is my send email function...
Mail::send('mails.thanks',['ticket'=>$request, 'department' => $department], function ($message) use ($departement){
$message->from(Config::get('const.email'), 'Ticket Plus');
$message->subject('Nueva tarea creada');
// get id user and send email user
$getUsers = User::where('department_id', [(int)$departement])->pluck('id')->toArray();
$role_users = DB::table('role_user')
->whereIn('user_id', $getUsers)
->where('role_id', 2)
->pluck('user_id')
->toArray();
$getMailUsers = DB::table('users')
->whereIn('id', $role_users)
->pluck('email')
->toArray();
foreach ($getMailUsers as $getMailUser)
{
$message->to($getMailUser);
};
// $message->to($settings->admin_email);
});
Thanks a lot..