I have a table for business and one for the employees.
I am trying to see whether a user already exists in the employee table with the same user_id and business_id, however, with my current code I am unsure how to do this.
My code:
if (BusinessEmployee::where('user_id', Auth::user()->id)->where('business_id', $business->id)) {
dd('already in business');
}
>Solution :
if (BusinessEmployee::where('user_id', Auth::user()->id)->where('business_id', $business->id)->exists()) {
dd('already in business');
}
or
$business = BusinessEmployee::where('user_id', Auth::user()->id)->where('business_id', $business->id);
if($business->exists())
{
dd('already in business');
}