Reputation: 743
i have 2 button accept and reject
when i die dump request is coming fine with accept id 2 and reject id 3
but i try to add if statement its bring me only accept skip reject
here is my code
$interview = Interview::find($request->id);
$user = Currentuser::where('id', $interview->CompanyID)->first();
if ($request->Status = '2') {
$data = []; // Empty array
Mail::send('email.useracceptjob', $data, function($message) use ($user){
$message->to($user->Email)->subject('Your Job Accepted By user');
});
}
elseif ($request->Status = '3') {
$data = []; // Empty array
Mail::send('email.userrejectjob', $data, function($message) use ($user){
$message->to($user->Email)->subject('Your Job Rejected By user');
});
}
else{
return response()->json(['code' => 500]);
}
do i doing something wrong? Help me Please
Upvotes: 0
Views: 70
Reputation: 688
The logical operator in your if
statement is like if ($request->Status = '2')
but you have to do it like if ($request->Status == '2')
or if you need to check the same value and type of data use if ($request->Status === '2')
I hope it helps.
Upvotes: 1
Reputation: 673
You must use double or triple equals when doing a logical compare
$request->Status == '2'
Of if you know it will be a string for sure, then triple equals is better
$request->Status === '2'
Upvotes: 0