0

Im new in laravel and wanted to redirect customers to specific page if this condition is valid but there is problem can you help me

 if (Customer::where(('customer_id', 'LIKE', $request->customer_id)&&('package_id'==2))->exists()){

return view('index.customer.customerabout'); 

2 Answers2

1

Try this

if(Customer::where('customer_id', 'LIKE', $request->customer_id)->where('package_id', 2)->count() > 1) {

    // .......

}
Abid Raza
  • 745
  • 8
  • 15
0

You can use multiple where statements for and condition. For OR condition you can use orWhere. To check if it exists you should check if count is greater than 0.

if(Customer::where('customer_id', 'LIKE', $request->customer_id)->where('package_id', 2)->count() > 0) {
// your code here 
} 

if you want to use OR operator you can do this

if(Customer::where('customer_id', 'LIKE', $request->customer_id)->orWhere('package_id', 2)->count() > 0) {
// your code here 
}
Abdul Basit
  • 394
  • 3
  • 12