I make a clone system in Laravel. I want to clone activities.
When I click on "Clone", my line is cloned and receives as the value in the column "parent_id" the ID of the original.
The original gets a value of 1 in the "hasClone" column.
But when I want to delete a clone, in my destroy method, I try to set hasClone (the original entry) to NULL before deleting the clone.
Here is my code :
public function destroyChanges(Activity $activity)
{
$parentActivity = Activity::findOrFail($activity->parent_id)->first();
$parentActivity->hasClone = NULL;
$parentActivity->save();
$activity->delete();
return redirect()->to('/admin/activity/');
}
Here is my route :
Route::delete('activity/destroyChanges/{id}', ['as' => 'cancel.activity', 'uses' => 'ActivityCrudController@destroyChanges']);
The entry of the clone is deleted correctly. But he does not update the original entry. How to do ? thank you very much
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2k9vUOc
via IFTTT
Aucun commentaire:
Enregistrer un commentaire