Skip to content

Commit

Permalink
Testing delete of materias
Browse files Browse the repository at this point in the history
  • Loading branch information
MatheusTKoch committed Jan 27, 2024
1 parent ea956c2 commit d2912f5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/MateriaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
10 changes: 8 additions & 2 deletions resources/js/Pages/Materias.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const submit = () => {
});
};
function deleteMateria(id) {
this.$inertia.delete(route('materias.destroy', id));
};
const prop = defineProps({
materias: ''
});
Expand Down Expand Up @@ -48,7 +52,9 @@ const prop = defineProps({
<InputError class="mt-2" :message="form.errors.materias"/>

<div class="flex items-center">
<PrimaryButton class="ml-4" :class="{ 'opacity-25': form.processing }" :disabled="form.processing">
<PrimaryButton class="ml-4"
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing">
Cadastrar
</PrimaryButton>
</div>
Expand All @@ -63,7 +69,7 @@ const prop = defineProps({
<li>
<div class="flex justify-center p-4" :key="index">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-5 text-gray-900">{{ mat.nome }}<SecondaryButton>Deletar</SecondaryButton></div>
<div class="p-5 text-gray-900">{{ mat.nome }}<SecondaryButton @click="deleteMateria()">Deletar</SecondaryButton></div>
</div>
</div>
</li>
Expand Down
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit d2912f5

Please sign in to comment.