BelongsToMany Full Name Accessor
I have
in Course Model have
When call Tables\Columns\TextColumn::make('courses.full_name')
Getting empty field.
How can I solve this?
14 Replies
This is because we use the column names in the query, not as an accessor.
do
getting Property [full_name] does not exist on this collection instance.
try
$record->courses->fullName
already tried with this:
fullName not resolving
this one working fine
Also I noted if working with belongsTo then Tables\Columns\TextColumn::make('course.full_name') working
virtual column much better as @Leandro Ferreira described!
yes, and you can also use this with
->searchable()
I use searchable with array like searchable(['name', 'surname'])
Can you explain why course.full_name working, but courses.full_name not working. belongsTo vs belongsToMany
I think this should work..
When call Tables\Columns\TextColumn::make('courses.full_name')
Getting empty field.
Did you try another column?
yes Tables\Columns\TextColumn::make('courses.course') working
in Subject Model
I thought you were using virtual column..
I don't using virtual column, because I use JSON fields for multilanguage.