Skip to main content

HasMany: Delete Parent - What Happens with Children?

Premium
10:53

The Full Lesson is Only for Premium Members

Want to access all of our courses? (36 h 00 min)

You also get:

61 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Thananjeyan G avatar

Hi Povilas,

I followed your vidoes about softdeletes, it works fine.

Contacts page

@foreach ($contacts as $contact)
	 Name : {{ $contact->name }} <br>
    Mobile : {{ $contact->name }} <br>
    Company : {{ $contact->company->name ?? null }} <br>
@endforeach

I need to show $contact->company->name value even if i deleted. How to solve this ??

Thank you.

Povilas Korop avatar

In Controller, Contact::withTrashed('company') from what I remember. Or add withTrashed() when defining the company relationship in Contact model.

Thananjeyan G avatar

Contact::withTrashed('company') - This method not working.

  • Its working - withTrashed() when defining the company relationship in Contact model.

Thanks

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.