Level 2
Dec 25, 2023
1
Level 2
Inertia not updating data after a redirect()->back()
Hi there, A problem I am having is that when I make a change to a model and when I redirect back, Inertia does not update the data. It updates the data only after a page refresh.
This is my code:
Index.vue
<td v-if="!school.deleted_at" class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-3">
<Link method="delete" :href="route('school.destroy', [school])" class="text-red-500 hover:text-red-600">
Delete
</Link>
</td>
<td v-else class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-3">
<Link method="put" :href="route('school.restore', [school])" class="text-green-500 hover:text-green-700/90">
Restore
</Link>
</td>
SchoolController.php
public function restore(School $school)
{
$school->restore();
return redirect()
->back()
->with('success', 'School restored successfully');
}
Thanks for your help.
Please or to participate in this conversation.