return Event::with('city.companies.persons')->get();
If you only want to select certain fields from the persons
table, use this:
return Event::with(['city.companies.persons' => function ($query) {
$query->select('id', '...');
}])->get();
More Related Contents:
- Laravel one to many relation with a one to one relation
- How to use multiple databases in Laravel
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- Using PHP data in MySQL [closed]
- Automated or regular backup of mysql data
- strange character encoding of stored data , old script is showing them fine new one doesn’t
- How to do this in Laravel, subquery where in
- PDO mysql: How to know if insert was successful
- How to loop through a mysql result set
- How to successfully rewrite old mysql-php code with deprecated mysql_* functions?
- Fetching single row, single column with PDO
- Is there any way to check the performance of mysql Indexing
- IP address storing in MySQL database using PHP [duplicate]
- Proper Repository Pattern Design in PHP?
- “No such file or directory” or “No such host is known” when running migrations
- Laravel 5.4 on PHP 7.0: PDO Exception – Could not find driver (MySQL)
- Using LIKE in bindParam for a MySQL PDO Query [duplicate]
- Laravel Eloquent get results grouped by days
- php artisan migrate throwing [PDO Exception] Could not find driver – Using Laravel
- Change name of Laravel’s created_at and updated_at
- How do I get database column names in Laravel?
- Laravel Change Connection Dynamically
- mysqli – fetch_Array error call to a member function fetch_array() on a non-object mysqli [duplicate]
- Eloquent many-to-many-to-many – how to load distant relation easily
- Mysql InnoDB engine in Laravel
- PHP Laravel: No connection could be made because the target machine actively refused it
- Auto Increment skipping numbers?
- How to get last inserted id from table MySQL [duplicate]
- Check if laravel model got saved or query got executed
- find in set in laravel ? example