Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel How to query foreign relations data along with multiple main records

$rooms = Room::with(["topic", "owner", "users"])->offset(($page - 1) * $total_posts)->limit($total_posts)->orderBy("id", "desc")->get();


    public function topic()
    {
        return $this->belongsTo(Topic::class);
    }

    public function owner()
    {
        return $this->belongsTo(User::class);
    }

    public function users()
    {
        return $this->belongsToMany(User::class, "room_users");
    }
Comment

PREVIOUS NEXT
Code Example
Php :: get table row data onclick 
Php :: Undefined property: CI::$file 
Php :: Condition 
Php :: Problems with Special Characters between Angular http post and PHP 
Php :: remove ul container from wp_nav_menu 
Php :: symony type request 
Php :: session flash data (old input) 
Php :: Dorf SMS Plugin 
Php :: export csv file in laravel 
Php :: laravel command Retrieve a specific option 
Php :: larvel still laod the local file location on production 
Php :: laravel app not loading on server 
Php :: laravel gigapay get single payout 
Php :: wp wc trim zero 
Php :: laravel select error 
Php :: return user details from controller to view 
Php :: kinsta check environment 
Php :: selecting a time zone from a drop-down list 
Php :: what is livewire 
Php :: shop manager Redirect @ WooCommerce 
Php :: Rewrite .php file without .php extension with .htaccess ULTIMATE SOLUTION 
Php :: Type cast using int php 
Php :: Get and access to the order data properties (in an array of values): 
Php :: remove number after decimal in php 
Php :: wpmu assign user to blog 
Php :: laravel eloquent where date today 
Php :: add code return block phpstorm 
Php :: php int to indonesian rupiah 
Php :: laravel scope query 
Php :: html table to array php 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =