This repo contains a Datatable that can render a filterable and sortable table. It aims to be very lightweight and easy to use. It has support for retrieving data asynchronously, pagination and recursive searching in relations.
I have a model that has a hasOne relation "Info" that also has a hasOne relationship "subject"
//table model
public $columns = [
... ,
[
'data' => 'info.subject.name',
'name' => 'info.subject.name',
'class' => 'subjectArea',
'searchable' => false,
"columnSearch" => true,
],
];
public function query($query)
{
return $query
->whereHas('info', function($query){
// $query->with('subject_area'); // have tried quite a few things here still lost
})
->with('user', 'status', 'info', 'info.subject') //tried multiple things here as well just can't find right combination
->withTrashed();
//initial model
public function info()
{
return $this->hasOne(\App\Models\EnrollmentAssistanceInfo::class);
}
//EnrollmentAssistanceInfo model
public function subject()
{
return $this->hasOne(\App\Models\CourseSubjectArea::class, 'id', 'subject_area');
}
when I attempt to do a search the query is broken.
Column not found: 1054 Unknown column 'subject' in 'where clause'
what do I need to do to my query function to make it search and sort the subject field?
and when i try to sort that column the ajax goes out but no sorting happens and i do not receive an error.
I have a model that has a hasOne relation "Info" that also has a hasOne relationship "subject"
when I attempt to do a search the query is broken.
what do I need to do to my query function to make it search and sort the subject field? and when i try to sort that column the ajax goes out but no sorting happens and i do not receive an error.