Donations Appreciated

It's not how much we give but how much love we put into giving. - Mother Teresa

RelationController.php - Morph To Many Demo

NOTE: MorphToMany only works for search. Sorting is subjective since it will do nothing if the orderable column is from a morphToMany relationship.
Id Title Tag


    public function getMorphToMany(Request $request)
        if ($request->ajax()) {
            $query = Post::with('tags')->select('posts.*');

            return $this->dataTable->eloquent($query)
                ->addColumn('tags', function (Post $post) {
                    return $post->tags->pluck('name')->implode('<br>');

        return view('datatables.relation.morph-to-many', [
            'title'      => 'Morph To Many Demo',
            'controller' => 'Relation Controller',


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