Eloquent DataTable with Belongs To Many

Id Title Created At Updated At Action

HTML

<table id="posts-table" class="table table-bordered">
    <thead>
    <tr>
        <th>Id</th>
        <th>Title</th>
        <th>Created At</th>
        <th>Updated At</th>
        <th>Action</th>
    </tr>
    </thead>
</table>

Routes

<?php

Route::get('eloquent/relations/belongs-to-many', 'Eloquent\Relations\BelongsToManyController@index');
Route::get('eloquent/relations/belongs-to-many-data', 'Eloquent\Relations\BelongsToManyController@data');

Controller

<?php

namespace App\Http\Controllers\Eloquent\Relations;

use App\Http\Controllers\Controller;
use App\User;
use Yajra\Datatables\Datatables;

class BelongsToManyController extends Controller
{
    /**
     * Display index page.
     *
     * @return \BladeView|bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        return view('eloquent.relations.belongs-to-many');
    }

    /**
     * Process dataTable ajax response.
     *
     * @param \Yajra\Datatables\Datatables $datatables
     * @return \Illuminate\Http\JsonResponse
     */
    public function data(Datatables $datatables)
    {
        $query = User::first()->blogs()->select('posts.*');

        return $datatables->eloquent($query)
                          ->addColumn('action', 'eloquent.tables.posts-action')
                          ->make(true);
    }
}

JS