samedi 24 septembre 2016

Deleting related rows with laravel

I am trying to delete all related rows in Laravel with:

$customers = Customer::find($clientId);
$customers->delete();
$customers->locations()->delete();
$customers->locations->objects()->delete();
$customers->locations->objects->subscriptions()->delete();
$customers->locations->objects->history()->delete();

And also tried:

$customers = Customer::find($clientId);
$customers->delete();
$customers->locations()->delete();
$customers->locations()->objects()->delete();
$customers->locations()->objects()->subscriptions()->delete();
$customers->locations()->objects()->history()->delete();

Laravel deletes the customer and locations but does not delete the objects, subscriptions and history and trows an error.

What can I do to delete them too?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire