Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel wherehas

$users = User::whereHas('posts', function($q){
    $q->where('created_at', '>=', '2015-01-01 00:00:00');
})->get();
// only users that have posts from 2015 on forward are returned
Comment

how to use whereHas in laravel

//https://laravel.com/docs/9.x/queries#conditional-clauses

$result = $query
    ->where('precedence', '=', $precedenceStatus)
    ->when($person, function ($query) use ($person) {
        $query->whereHas('personnel', fn ($q) => $q->where('id', '=', $person));
    })
    ->get();
Comment

PREVIOUS NEXT
Code Example
Php :: laravel resource api 
Php :: php array current 
Php :: resource route controller laravel 8 
Php :: laravel casts AsCollection 
Php :: woocommerce my account php code wordpress 
Php :: laravel check if primary key exists 
Php :: string length laravel validation 
Php :: laravel edit form modal example 
Php :: echo php dropdown from db and save it in a db 
Php :: laravel drop column softdeletes 
Php :: reverse string php 
Php :: PHP temporary files 
Php :: carbon get month from date 
Php :: how change resource route parameters lravel 
Php :: wp-config.php 
Php :: copy file in php 
Php :: naming convention for magento2 custom cms page index xml file 
Php :: laravel migration tinyint length 
Php :: php ErrorException Undefined variable inside array_map 
Php :: php get json objects by key without indez 
Php :: get url parameter laravel 5.2 constructor 
Php :: Remove the Breadcrumb on the Shop Page 
Php :: PHP is not configured to connect to MySQL 
Php :: multiple primary key defined laravel 
Php :: wordpress get the short permalink 
Php :: log magenot 1 
Php :: laravel validation two columns unique 
Php :: laravel allow all fillable 
Php :: How to run PHP script every 5 minutes 
Php :: wordpress filter category from widget 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =