Q:

How to display related items in datatable?

I currently display all restaurants in a datatable, but restaurants can also have branches/franchises, so I am trying to display these as well in the same table.
At the moment I display them as follows:
if ($request->ajax()) {
    $restaurant = Restaurant::query()->with('user');

    return Datatables::of($restaurant)
        ->editColumn('name', function ($restaurant) {
            return $restaurant->name;
        })
        ->editColumn('user.name', function ($restaurant) { // Owner
            return $restaurant->user->name;
        })
        ->editColumn('total_orders', function ($restaurant) {
            return $restaurant->total_orders;
        })
        ->make(true);
}

My relationship is that Restaurant hasMany(Branch::class); and Branch belongsTo(Restaurant::class);
I fail to think of a solution that allows me to display all the branches ($restaurant->branches->get()) inside the same restaurant datatable.
Any help and hints would be great!

A:

Although you can do this with the query builder and then do multiple joins I prefer to do it like this. 
$restaurant = Restaurant::select('restaurant.name as name, user.name as owner,         
     restaurant.total_orders as total_orders, branches.*')
->with('user', 'branches');

