mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-04 15:26:43 +02:00
refactor: harmonize redirects after submitting forms
go back to form after submitting an edit form
This commit is contained in:
parent
6e9451a110
commit
d0cb964b0f
36 changed files with 179 additions and 57 deletions
|
|
@ -205,7 +205,10 @@ class EpisodeController extends BaseController
|
|||
|
||||
$db->transComplete();
|
||||
|
||||
return redirect()->route('episode-view', [$this->podcast->id, $newEpisodeId]);
|
||||
return redirect()->route('episode-view', [$this->podcast->id, $newEpisodeId])->with(
|
||||
'message',
|
||||
lang('Episode.messages.createSuccess')
|
||||
);
|
||||
}
|
||||
|
||||
public function edit(): string
|
||||
|
|
@ -334,11 +337,18 @@ class EpisodeController extends BaseController
|
|||
|
||||
$db->transComplete();
|
||||
|
||||
return redirect()->route('episode-view', [$this->podcast->id, $this->episode->id]);
|
||||
return redirect()->route('episode-edit', [$this->podcast->id, $this->episode->id])->with(
|
||||
'message',
|
||||
lang('Episode.messages.editSuccess')
|
||||
);
|
||||
}
|
||||
|
||||
public function transcriptDelete(): RedirectResponse
|
||||
{
|
||||
if ($this->episode->transcript === null) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$mediaModel = new MediaModel();
|
||||
if (! $mediaModel->deleteMedia($this->episode->transcript)) {
|
||||
return redirect()
|
||||
|
|
@ -352,6 +362,10 @@ class EpisodeController extends BaseController
|
|||
|
||||
public function chaptersDelete(): RedirectResponse
|
||||
{
|
||||
if ($this->episode->chapters === null) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$mediaModel = new MediaModel();
|
||||
if (! $mediaModel->deleteMedia($this->episode->chapters)) {
|
||||
return redirect()
|
||||
|
|
@ -699,16 +713,18 @@ class EpisodeController extends BaseController
|
|||
(new PostModel())->removePost($post);
|
||||
}
|
||||
|
||||
// set episode published_at to null to unpublish before deletion
|
||||
$this->episode->published_at = null;
|
||||
|
||||
$episodeModel = new EpisodeModel();
|
||||
if (! $episodeModel->update($this->episode->id, $this->episode)) {
|
||||
$db->transRollback();
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $episodeModel->errors());
|
||||
if ($this->episode->published_at !== null) {
|
||||
// if episode is published, set episode published_at to null to unpublish before deletion
|
||||
$this->episode->published_at = null;
|
||||
|
||||
if (! $episodeModel->update($this->episode->id, $this->episode)) {
|
||||
$db->transRollback();
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput()
|
||||
->with('errors', $episodeModel->errors());
|
||||
}
|
||||
}
|
||||
|
||||
$episodeModel->delete($this->episode->id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue