0
There is a model in my application called payment that belongs to a user. I pull the information with
Pagamento::latest()->with('user');
That way if a user is deleted, even if he already has soft delete, he is not returned. How to return it along with payments?
So, basically I want to include users deleted by soft-delete in this query. Some way to put a withTrashed()
for the user in this query.
It has been solved and created another! If you can not delete user if he has relationship understands?
– novic
I don’t think @Virgilionovic because he is using Laravel softDelete, the user data will continue in the database, only the column
deleted_at
will be filled and this user will not be displayed within the system if he does not use this function ofwithTrashed
– Kayo Bruno
Yes @Kayobruno but, what was done in this reply limits the user to do only this way, it would be better to create a Scope query for this, or a relationship of his own.
– novic
@Virgilionovic I agree with you that creating a query Cope for this would be much better, I’m not saying you’re wrong I just didn’t understand when you said "limit the user to do only this way". kkkk
– Kayo Bruno
because generally @Kayobruno the relation function
user
is to bring users and you limit yourself with an extra query in the function. That’s it...– novic
@Virgilionovic now understood, yes it really makes sense. Thank you for having clarified even though I took a long time to understand rsrsr.
– Kayo Bruno