Closed cesarureno closed 6 years ago
Hi Use the "with" method on the query to eager load the relation and add the column:
'country_id' => ['name' => 'countries.name', 'data' => 'countries.name', 'title' => 'Country'],
PS: what theme are you using?
Thank you @dhcmega
@cesarureno Hi, can you please tell which style you've used for the table? I need something like your screenshot. Thanks!
@mitulgolakiya It might be a good idea to add NAME tag along side with DATA to that post. Even though it's not the scope of the post.
Not doing so, when using search, it will trigger a MySQL error if relation is composed of multiple words.
No including 'name' => 'surveyQuestion.question',
will generate this error:
Column not found: 1054 Unknown column 'survey_question.question'
(note the missing S in table's name)
@dhcmega
(note the missing S in table's name)
I didn't get this line.
Hi! Sorry, maybe I'm wrong. I remember I have tested it and if you don't include the 'name' element in the array, only 'data' with the eloquent relation, when using search feature the table name gets rendered as the relation in snake case in singular, without the final S that the table will probably have.
In my test, the table name is survey_questions
and the relation is 'surveyQuestion', but it gets converted to 'survey_question.question' and MySQL give and error.
This problem gets solved by also adding 'name' element.
Does it make sense?
Thanks again
yes.
here is tutorial
How can get custom data from relationship? I need display country name