HasOneThrough need some help #270
Unanswered
eisigeflamme
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
i need your help, maybe its only o small problem for you, but i cant find out how to solve this.
I have got 3 Model
Assessment
id
checked_by (relation with User via user_code)
object_id (relation with Object)
Object
id
User
id
user_code
I want to display Objects, which has Assessments with the Name of User who did the inspection.
I could do it so far with a HasOneThrough Relation
in my Table i am using the follwing call to get the data
public function datasource(): ?Builder
{
->with(['inspector' => function ($query) {
$query->select(['users.name']);
}]);
}
Here i try to get only the name of the User who did the inspection
public function columns(): array
{
return [ Column::add()
->title('Checked by')
->field('inspector')
->searchable(),];
}
So my problem is now that in my table it displays the full object instead of the name. And i can´t figure out how to get only the name of the user.
Maybe someone can help me on this problem? Do i need something special to convert this to an object and display its attributes?
Thanks for your help.
Beta Was this translation helpful? Give feedback.
All reactions