refactor: harmonize redirects after submitting forms

go back to form after submitting an edit form
This commit is contained in:
Yassine Doghri 2022-01-05 14:58:53 +00:00
commit d0cb964b0f
36 changed files with 179 additions and 57 deletions

View file

@ -124,12 +124,13 @@ class PostController extends Controller
'published_at' => Time::now(),
]);
if (! model('PostModel')->addPost($newPost)) {
$postModel = model('PostModel');
if (! $postModel->addPost($newPost)) {
return redirect()
->back()
->withInput()
// TODO: translate
->with('error', "Couldn't create Post");
->with('error', $postModel->errors());
}
// Post without preview card has been successfully created