diff --git a/app/Http/Controllers/MateriaController.php b/app/Http/Controllers/MateriaController.php index 77664831..ab3efbbf 100644 --- a/app/Http/Controllers/MateriaController.php +++ b/app/Http/Controllers/MateriaController.php @@ -73,8 +73,8 @@ public function update(Request $request, string $id) /** * Remove the specified resource from storage. */ - public function destroy(string $id) + public function destroy( $id) { - + Materia::find($id)->delete(); } } diff --git a/resources/js/Pages/Materias.vue b/resources/js/Pages/Materias.vue index 92933986..caad6ad0 100644 --- a/resources/js/Pages/Materias.vue +++ b/resources/js/Pages/Materias.vue @@ -17,6 +17,10 @@ const submit = () => { }); }; +function deleteMateria(id) { + this.$inertia.delete(route('materias.destroy', id)); +}; + const prop = defineProps({ materias: '' }); @@ -48,7 +52,9 @@ const prop = defineProps({
- + Cadastrar
@@ -63,7 +69,7 @@ const prop = defineProps({
  • -
    {{ mat.nome }}Deletar
    +
    {{ mat.nome }}Deletar
  • diff --git a/routes/web.php b/routes/web.php index 1fa56374..5a58cbf2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -51,7 +51,7 @@ Route::controller(MateriaController::class)->group(function() { Route::get('/materia', 'index')->name('materia'); Route::post('/materia', 'store')->name('materia'); - Route::post('/materia', 'destroy')->name('materia'); + Route::delete('/materia', 'destroy')->name('materia'); })->middleware(['auth', 'verified']); Route::controller(ProvaController::class)->group(function() {