Adjust class file controller

This commit is contained in:
paoloGuagnano
2024-02-26 16:32:53 +01:00
parent 4471b5e509
commit ac5fdc3909
4 changed files with 18 additions and 20 deletions

View File

@@ -34,7 +34,7 @@ class WordsController extends Controller
$word->translation = $request->translation;
$word->save();
return redirect('/words');
return redirect('/words')->withSuccess('The Italian word and its translation have been successfully saved.');
}
/**
@@ -78,7 +78,7 @@ class WordsController extends Controller
$data->save();
// Redirect to a success route or return a success message
return redirect('/words');
return redirect('/words')->withSuccess('The Italian word and its translation has been successfully changed.');
} else {
// Unique constraint violated
return back()->withInput()->withErrors(['name' => 'Error: words already exists']);
@@ -91,6 +91,6 @@ class WordsController extends Controller
public function delete($id): RedirectResponse
{
Word::destroy($id);
return redirect('/words');
return redirect('/words')->withSuccess('The Italian word and its translation has been successfully deleted.');
}
}