Got Problem in Relation Table Column
So, i want to show the author name with this relation, but in the table the name of the author is not show. Need help
Solution:Jump to solution
if you changed the relationship name to
author_model
then use author_model.name
in your table11 Replies
What will show if u only use author without the .name?
just author's id
seems to me that your relationship to authors is not right in your Discussion model. The key should be your local key for authors, which seems to be
author
is that an absolute problem, or there is another possibility that causing this problem? because i tried to change the relation from
author
to authors
its make 500 error codeI'm sorry if it wasn't clear, this is what I think your
belongsTo
relation should look like:
then you should be able to use author.name
assuming in your members
table your primary key is id
in relation manager it's fixed. but, in the table it gives me error
Undefined property: App\Models\Discussion::$author
yes it isok, it looks like it's confusing the
author
property (which is the author id, right?) and the author
relationship.
try changing your relation to something different, like public function author_model(): BelongsTo
or anything different from author
and the use that as the relationship name.and its still like the beginning,
author.name
is not showing anything in the tableSolution
if you changed the relationship name to
author_model
then use author_model.name
in your tableoh gosh, i didn't think of it cause it's almost morning in my country and quite tired with this problem 😂, thank you so much!
happy to help, and get some sleep! 😉