There is no exercise better for the heart than reaching down and lifting people up. - John Holmes
Id | Title | Author |
---|
public function getBelongsTo(Request $request)
{
if ($request->ajax()) {
$query = Post::with('user')->select('posts.*');
return $this->dataTable->eloquent($query)->make(true);
}
return view('datatables.relation.belongs-to', [
'title' => 'Model Belongs To Demo',
'controller' => 'Relation Controller',
]);
}
$('#users-table').DataTable({
processing: true,
serverSide: true,
ajax: '',
columns: [
{data: 'id', name: 'posts.id'},
{data: 'title', name: 'posts.title'},
{data: 'user.name', name: 'user.name'},
{data: 'user.email', name: 'user.email'}
]
});