Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Laravel - Add conditional where clause in query

$user_to_mail = User::where('store_id', $item->store_id)
                    ->when($store->notification_role_id > 0, function ($q) use ($store) {
                        return $q->where('role_id', $store->notification_role_id);
                    })
                    ->get();
Comment

PREVIOUS NEXT
Code Example
Php :: laravel pagination limit page 
Php :: wordpress change slug programmatically 
Php :: display name cat product woocommerce 
Php :: removing the last value of an array 
Php :: call_user_func() 
Php :: isset 
Php :: laravel edit form modal example 
Php :: laravel validation check foreign key exists 
Php :: Automatic Subdomain with PHP 
Php :: how to check if query is successfully inserted laravel 
Php :: sanctum 
Php :: how do i use $variables as values in php 7 mysqli insert 
Php :: php photo upload 
Php :: laravel how to nested foreach 
Php :: get all taxonomy name wordpress 
Php :: socket in laravel 
Php :: match uuid patter laravel regex 
Php :: wp php blog info image 
Php :: php increment variable 
Php :: laravel move/rename file ftp 
Php :: create config value file in php 
Php :: uft8 json php 
Php :: remove MainWP Child phpmyadmin 
Php :: How do I display logged-in username IF logged-in? site:wordpress.stackexchange.com 
Php :: php pass 2 date value to javascript 
Php :: is search page wordpress dev 
Php :: date in russian php 
Php :: php array_diff 
Php :: php obfuscate email 
Php :: latavel attach method 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =