laravel orWhere
$camps = $field->camps()->where('status', 0)->where(function ($q) {
$q->where('sex', Auth::user()->sex)->orWhere('sex', 0);
})->get();
laravel orWhere
$camps = $field->camps()->where('status', 0)->where(function ($q) {
$q->where('sex', Auth::user()->sex)->orWhere('sex', 0);
})->get();
laravel db::query update
DB::table('user')->where('email', $userEmail)->update(array('member_type' => $plan));
double where condition in laravel
$query->where([
['column_1', '=', 'value_1'],
['column_2', '<>', 'value_2'],
[COLUMN, OPERATOR, VALUE],
...
])
laravel where condition with if
$query = DB::table('user_ads')
->join('ads', 'users_ads.ad_id', '=', 'ads.id')
->orderBy($column, $method);
if ($input['search']) {
$query->where('short_description', $input['search']);
}
if ($input['category']) {
$query->where('category', $input['category']);
}
$query->join('users', 'users_ads.user_id', '=', 'users.id')
->select('ads.id', 'ads.img1', 'ads.short_description', 'ads.category', 'ads.product', 'ads.price', 'users.city')
$result= $query->get();
return $result;
laravel when condition
$invisiblePosts = $request->query('invisible');
Article::query()
->when($invisiblePosts , function ($query){
return $query->where('invisible' , true);
},function ($query){
return $query->where('invisible' , false);
})
->get();
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us