Closed djamesfar closed 2 years ago
This is a laravel behavior when serializing the model to array. Your column should be something like this:
'name' => 'quoteStatus.name',
'data' => 'quote_status.name',
Related docs: https://datatables.yajrabox.com/eloquent/relationships https://yajrabox.com/docs/laravel-datatables/master/relationships
getColumns() does not recognize camel-cased relation names
Using implementation in infyom/laravel-generator, I have a
quotes
table with several simplebelongsTo
relations to other tables. One is named in camel-cased convention:quoteStatus
, relating to the quote_statuses table using a foreign keyquote_status_id
. Datatables returned no data if I included `'defaultContent' => '', and an error if I removed this (relation not found).Code snippet of problem
from QuoteDataTables:
from Quote model (relation method in camel-case):
after changing Quote model relation name to slug case (works):
and changing getColumns() (works):
System details