Laravel 如何检查两个条件是否在控制器中有效
Laravel how to check if two conditions are validate in controller
我是 laravel 的新人,如果此条件有效,我想将客户重定向到特定页面,但有问题你能帮我吗
if (Customer::where(('customer_id', 'LIKE', $request->customer_id)&&('package_id'==2))->exists()){
return view('index.customer.customerabout');
试试这个
if(Customer::where('customer_id', 'LIKE', $request->customer_id)->where('package_id', 2)->count() > 1) {
// .......
}
您可以对和条件使用多个 where 语句。对于 OR 条件,您可以使用 orWhere。要检查它是否存在,您应该检查计数是否大于 0。
if(Customer::where('customer_id', 'LIKE', $request->customer_id)->where('package_id', 2)->count() > 0) {
// your code here
}
如果您想使用 OR 运算符,您可以这样做
if(Customer::where('customer_id', 'LIKE', $request->customer_id)->orWhere('package_id', 2)->count() > 0) {
// your code here
}
我是 laravel 的新人,如果此条件有效,我想将客户重定向到特定页面,但有问题你能帮我吗
if (Customer::where(('customer_id', 'LIKE', $request->customer_id)&&('package_id'==2))->exists()){
return view('index.customer.customerabout');
试试这个
if(Customer::where('customer_id', 'LIKE', $request->customer_id)->where('package_id', 2)->count() > 1) {
// .......
}
您可以对和条件使用多个 where 语句。对于 OR 条件,您可以使用 orWhere。要检查它是否存在,您应该检查计数是否大于 0。
if(Customer::where('customer_id', 'LIKE', $request->customer_id)->where('package_id', 2)->count() > 0) {
// your code here
}
如果您想使用 OR 运算符,您可以这样做
if(Customer::where('customer_id', 'LIKE', $request->customer_id)->orWhere('package_id', 2)->count() > 0) {
// your code here
}