Donations Appreciated

The simplest acts of kindness are by far more powerful then a thousand heads bowing in prayer. - Mahatma Gandhi

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'},