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

PREVIOUS NEXT
Code Example
Php :: remove first 4 characters in string php 
Php :: Installing PHP and Configuring Nginx to Use the PHP Processor 
Php :: how to retrieve image from database in php mysqli 
Php :: php curl Content-Length 
Php :: laravel apache public folder 
Php :: Laravel Code To Rename file on server in the storage folder 
Php :: codeigniter 4 limit query 
Php :: wpdb get results foreach 
Php :: wordpress php query randomise 
Php :: migration rename column laravel 
Php :: how to receive json data in php 
Php :: laravel append 
Php :: laravel command parameter optional 
Php :: get domain url with https in laravel 
Php :: php-curl 
Php :: Artisan command on live server 
Php :: get object tyhpe php 
Php :: how to change woocommerce read more text 
Php :: laravel collection concat 
Php :: running laravel queues in shared hosting 
Php :: php value to javascript variable laravel blade 
Php :: Increase the PHP memory limit 
Php :: in_array 
Php :: laravel multiple group by 
Php :: laravel logout current user 
Php :: laravel query builder get last insert id 
Php :: <?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * Main loader script * * @package PhpMyAdmin */ declare(strict_types=1); 
Php :: format date laravel timestamp view 
Php :: Instalar Lamp server en Ubuntu 
Php :: get user by meta wp 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =