Donations Appreciated

You have not lived today until you have done something for someone who can never repay you. - John Bunyan

Click here to lend your support to: Laravel Datatables and make a donation at !

RelationController.php - Has Many Demo

Id Name Email Post


    public function getHasOne(Request $request)
        if ($request->ajax()) {
            $query = User::with('posts')->select('users.*');

            return $this->dataTable
                ->addColumn('title', function (User $user) {
                    return $user->posts->map(function($post) {
                        return str_limit($post->title, 30, '...');

        return view('datatables.relation.has-one', [
            'title' => 'Has Many Eager Loading Demo',
            'controller' => 'Relation Controller',


        processing: true,
        serverSide: true,
        ajax: '',
        columns: [
            {data: 'id', name: ''},
            {data: 'name', name: ''},
            {data: 'email', name: ''},
            {data: 'title', name: 'posts.title'},