-
$outcomeis not passed to the view. -
titlehas the string value ofPolls - What is wrong with your output?
- And what do you mean by synchronicity? I have never come across this term before.
Synchronicity issue when deleting model and related records.
Good afternoon everybody,
Sorry if this might be a simple question, but coulnd't find a solution anywhere. In a controller, I'm trying to delete a Poll object and all the related Questions elements, then show a view where i expect not to see the deleted poll, but when the view is rendered, the code is there. My code is:
if ($poll) {
// PollQuestion::where('poll_id', $poll->id)->delete();
// -- DELETES BUT IS SHOWN IN VIEW
// $poll->questions()->delete()
// -- DELETES BUT IS SHOWN IN VIEW
$outcome = $poll->delete();
}
// sleep(1); -- DOESN'T HELP EITHER!
return view('content.polls', [
'title' => 'Polls',
]);
If I refresh the view or check in the database, the deleted poll and the questions are gone, so it appears to be a synchronicity problem.. but I didn't expect that in PHP, especially considering that even a dirty sleep() function didn't solve the issue. In other controllers where I simply delete the model the problem doesn't show. My Laravel version is 7.13.0
May anyone help? thanks in advance!
Please or to participate in this conversation.