An Owner has many Cars...
And in my blade page I have this...
{{{$car->Owner->name}}}
And that works except that the query is adding...
where 'owners'.'deleted_at' is null
which I don't want.
I've tried variations of...
{{{$car->Owner->withTrashed()->name}}}
{{{$car->Owner()->withTrashed()->name}}}
{{{$car->withTrashed()->Owner->name}}}
None of which work.
What is the correct way?
Thanks!
Respectful bump.
I just want to be able to control what queries use the deleted_at column.
I'm thinking the answer may be to just disable the automatic soft-deleting and add a scope element to the model.
When you call the relationship as a function, it creates a new query builder. So you need to use get() or first() in order to use the results:
$car->owner()->withTrashed()->first()->name
See this section of the docs for more info: http://laravel.com/docs/eloquent#one-to-many
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community