Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel where and or condition

$users = User::where('active','1')->where(function($query) {
			$query->where('email','jdoe@example.com')
						->orWhere('email','johndoe@example.com');
})->get();
Comment

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();
Comment

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;
Comment

laravel if else condition in query

$query = SocialMediaFeed::where('location_id', $location_id);
if(!$filters) {
    $query = $query->where('self', '<>', true);
} else {
    $query = $query->orWhere('self', true);
}
Comment

PREVIOUS NEXT
Code Example
Php :: laravel schedule kernel code sample 
Php :: divide page in pdf with page break using php 
Php :: How to get a list of registered route paths in Laravel? 
Php :: php How to remove from a multidimensional array all duplicate elements including the original 
Php :: laravel group concat values showing duplicate 
Php :: Bootstrap paginator css not appearing 
Php :: check count in laravel 
Php :: php multi string to single string 
Php :: split date range into weeks php 
Php :: coinbase commerce laravel 
Php :: group by count mongodb laravel 
Php :: laravel get route 
Php :: laravel 8 livewire tutorial 
Php :: curlopt_postfields php example 
Php :: This domain is not registered with Tiny Cloud. Please see the quickstart guide or create an account. 
Php :: wp wordPress variables de session 
Php :: What template files are used for our custom post type in wordpress? 
Php :: png to pdf 
Php :: mysql gone away error in php 
Php :: php if isset 
Php :: laravel best practices 
Php :: php replace url parameter value 
Php :: php interview questions for 2 year experience 
Php :: echo foreach 
Php :: how to separate admin and user login in laravel 
Php :: create laravel update 
Php :: move wordpress to new server 
Php :: how to lookup value inside object php 
Php :: php "?int" 
Php :: how to create object in php 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =