Open roulendz opened 8 years ago
@roulendz You have to use join
to explicitly join the related tables, then you'll have access to the related table's underlying columns. Then, you make a alias column out of it.
$query = User::join('groups', 'user.group_id', '=', 'group.id')
->select(['users.*', 'groups.name as group_name']
->paginate();
You will then have additional column named group_name
and your can filter it as well.
Then, you can tell vuetable to use that column as a sort field. This will make it sortable on vuetable as well.
// fields definition
var tableColumns = [
{
name: 'start',
title: 'Date',
sortField: 'Date',
callback: 'formatDate'
},
{
name: 'group_id',
title: 'Group',
sortField: 'group_name' // <-- specify the sort field to use here
}
{
name: '__actions',
title: '',
titleClass: 'text-center',
dataClass: 'text-center',
}
]
Hi, The data structure is the same as a Laravel pagination that I return from the server. But already sorted it out.
I can not figue out how to filter eloquent relationships.
I have event, inside witch I have school_id, lesson_id, student_id. And I want to be able to filter, event.lesson.title, or event.school.title
How I can do it? web.php
vuetable.js