Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel eager loading pass variable in withCount where condition

$user = 1;
                       
Forum::with(['posts' => function($query) use ($user){
    $query->withCount(['comments => function($query) use ($user){
            $query->where('id_user', $user); 
        }]);
}])
->get();
Comment

PREVIOUS NEXT
Code Example
Php :: How can apply_filters be used to create a filter hook in wordpress 
Php :: VerifyEmailController in Api 
Php :: add attribute to model laravel 
Php :: send emails with runtime configurations in laravelk 
Php :: php debug backtrace last function 
Php :: /usr/local/bin/php /home/tbmholdingltd/public_html/tugent/php artisan schedule:run /dev/null 2&1 
Php :: connecting to database and performing sql queries 
Php :: pht get header from request 
Php :: CakeResque::enqueue 
Php :: exceptions on fatals(2) 
Php :: upsert request php-salesforce-rest-api 
Php :: bitnami wp user pass change 
Php :: how hide hr tag in post wordpress 
Php :: php code inside html 
Php :: Detecting specifically the My account "Dashboard" page 
Php :: launch new tab and refresh original page codeigniter 
Php :: how to payment credit card in codeigniter authorized.net 
Php :: https://www.codegrepper.com/documentation.php 
Php :: php encrypt decrypt online 
Php :: laravel asset prevent browser caching 
Php :: How To Substract And Add Hours In Laravel Using Carabon? 
Php :: Dein Benutzer-Profil um weitere Social Media Accounts erweitern 
Php :: drupal 9 custom local stream wrapper 
Php :: php make simple loop of number elevated to exponent without pow 
Php :: get average of sql column php 
Php :: Builder Pattern Method Chaining 2 
Php :: list bulan php 
Php :: php get current datetime in us chicago 
Php :: php delete al lsession 
Php :: cakephp 3 get app url 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =