How to redirect back to edit page from a called function?How to manage a redirect request after a jQuery Ajax callHow do I redirect to another webpage?How do I make a redirect in PHP?How can I redirect and append both stdout and stderr to a file with Bash?How do I get a YouTube video thumbnail from the YouTube API?How do I redirect with JavaScript?StackOverflow Style Routes with Smart RedirectsHow discard empty HTML form inputs from $_FILES arrayWhen I route my controller it can't workLaravel redirect back and refresh.
How do professional electronic musicians/sound engineers combat listening fatigue?
Grid/table with lots of buttons
Is it normal practice to screen share with a client?
What is a reasonable time for modern human society to adapt to dungeons?
This message is flooding my syslog, how to find were it comes from?
Sextortion with actual password not found in leaks
How were the LM astronauts supported during the moon landing and ascent? What were the max G's on them during these phases?
401(k) investment after being fired. Do I own it?
What is the purpose of the fuel shutoff valve?
How can I receive packages while in France?
What was the rationale behind 36 bit computer architectures?
What is "ass door"?
Would it be a good idea to memorize relative interval positions on guitar?
What to do when you reach a conclusion and find out later on that someone else already did?
Can GPL and BSD licensed applications be used for government work?
How do I run a game when my PCs have different approaches to combat?
Who has jurisdiction for a crime committed in an embassy?
Where to place an artificial gland in the human body?
Can two figures have the same area, perimeter, and same number of segments have different shape?
Monty Hall Problem with a Fallible Monty
The seven story archetypes. Are they truly all of them?
Spacing setting of math mode
How can I make sure my players' decisions have consequences?
If my business card says 〇〇さん, does that mean I'm referring to myself with an honourific?
How to redirect back to edit page from a called function?
How to manage a redirect request after a jQuery Ajax callHow do I redirect to another webpage?How do I make a redirect in PHP?How can I redirect and append both stdout and stderr to a file with Bash?How do I get a YouTube video thumbnail from the YouTube API?How do I redirect with JavaScript?StackOverflow Style Routes with Smart RedirectsHow discard empty HTML form inputs from $_FILES arrayWhen I route my controller it can't workLaravel redirect back and refresh.
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
On edit.blade.page
there is a button for file deleting which leads to the update
method in a controller. The update
method calls private deleteImage
method from which I want to redirect a user back to edit.blade.page
, but it redirects me somewhere else.
I have tried all approach from the documentation
Controller
public function update(Request $request, $id)
($request['method']==true) ? $this->imageDelete($request, $id) : null;
private function imageDelete (Request $request, $id)
if($request['method']=='destroy')
$file = public_path().'/storage'.$request['old_image'];
$validatedData = $request->validate(['images'=> 'string',]);
$old_images = explode(',', $request['images']);
$paths = array();
foreach ($old_images as $old)
($old != $request['old_image']) ? $paths[] = $old : null ;
(File::exists($file)) ? File::delete($file) : null;
Announcement::where('slug', $id)->update(array_merge($validatedData,array('images'=>implode(",",$paths),)));
return redirect()->route('announcements.edit',[$id])->with('status',1);
return redirect()->route('announcements.edit',[$id])->with('status', 0);
Route
Route::resource('announcements', 'AnnouncementController', ['names' => [
'index' => 'announcements',
'store' => 'announcements.store',
'show' => 'announcements.show',
'destroy'=>'announcements.destroy',
'update' => 'announcements.update',
]])
php laravel redirect routes
add a comment |
On edit.blade.page
there is a button for file deleting which leads to the update
method in a controller. The update
method calls private deleteImage
method from which I want to redirect a user back to edit.blade.page
, but it redirects me somewhere else.
I have tried all approach from the documentation
Controller
public function update(Request $request, $id)
($request['method']==true) ? $this->imageDelete($request, $id) : null;
private function imageDelete (Request $request, $id)
if($request['method']=='destroy')
$file = public_path().'/storage'.$request['old_image'];
$validatedData = $request->validate(['images'=> 'string',]);
$old_images = explode(',', $request['images']);
$paths = array();
foreach ($old_images as $old)
($old != $request['old_image']) ? $paths[] = $old : null ;
(File::exists($file)) ? File::delete($file) : null;
Announcement::where('slug', $id)->update(array_merge($validatedData,array('images'=>implode(",",$paths),)));
return redirect()->route('announcements.edit',[$id])->with('status',1);
return redirect()->route('announcements.edit',[$id])->with('status', 0);
Route
Route::resource('announcements', 'AnnouncementController', ['names' => [
'index' => 'announcements',
'store' => 'announcements.store',
'show' => 'announcements.show',
'destroy'=>'announcements.destroy',
'update' => 'announcements.update',
]])
php laravel redirect routes
add a comment |
On edit.blade.page
there is a button for file deleting which leads to the update
method in a controller. The update
method calls private deleteImage
method from which I want to redirect a user back to edit.blade.page
, but it redirects me somewhere else.
I have tried all approach from the documentation
Controller
public function update(Request $request, $id)
($request['method']==true) ? $this->imageDelete($request, $id) : null;
private function imageDelete (Request $request, $id)
if($request['method']=='destroy')
$file = public_path().'/storage'.$request['old_image'];
$validatedData = $request->validate(['images'=> 'string',]);
$old_images = explode(',', $request['images']);
$paths = array();
foreach ($old_images as $old)
($old != $request['old_image']) ? $paths[] = $old : null ;
(File::exists($file)) ? File::delete($file) : null;
Announcement::where('slug', $id)->update(array_merge($validatedData,array('images'=>implode(",",$paths),)));
return redirect()->route('announcements.edit',[$id])->with('status',1);
return redirect()->route('announcements.edit',[$id])->with('status', 0);
Route
Route::resource('announcements', 'AnnouncementController', ['names' => [
'index' => 'announcements',
'store' => 'announcements.store',
'show' => 'announcements.show',
'destroy'=>'announcements.destroy',
'update' => 'announcements.update',
]])
php laravel redirect routes
On edit.blade.page
there is a button for file deleting which leads to the update
method in a controller. The update
method calls private deleteImage
method from which I want to redirect a user back to edit.blade.page
, but it redirects me somewhere else.
I have tried all approach from the documentation
Controller
public function update(Request $request, $id)
($request['method']==true) ? $this->imageDelete($request, $id) : null;
private function imageDelete (Request $request, $id)
if($request['method']=='destroy')
$file = public_path().'/storage'.$request['old_image'];
$validatedData = $request->validate(['images'=> 'string',]);
$old_images = explode(',', $request['images']);
$paths = array();
foreach ($old_images as $old)
($old != $request['old_image']) ? $paths[] = $old : null ;
(File::exists($file)) ? File::delete($file) : null;
Announcement::where('slug', $id)->update(array_merge($validatedData,array('images'=>implode(",",$paths),)));
return redirect()->route('announcements.edit',[$id])->with('status',1);
return redirect()->route('announcements.edit',[$id])->with('status', 0);
Route
Route::resource('announcements', 'AnnouncementController', ['names' => [
'index' => 'announcements',
'store' => 'announcements.store',
'show' => 'announcements.show',
'destroy'=>'announcements.destroy',
'update' => 'announcements.update',
]])
php laravel redirect routes
php laravel redirect routes
edited Mar 26 at 16:35
Virtual Device
asked Mar 26 at 16:12
Virtual DeviceVirtual Device
791 silver badge9 bronze badges
791 silver badge9 bronze badges
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Just use the route
helper with the redirect
helper to specify the route name you wish to go to:
return redirect()->route('your.route.name');
Note: This requires you to have named your route e.g.
Route::get('/test', 'SomeController@index')->name('test')
or you can pass the URL directly to redirect
.
I've generally found that being explicit in what I want my code to do prevents mistakes / unintended side-effects down the line.
Although in the first place, I posted withback()
method, I usually use this approach in my routing. Unfortunately, it doesn't work. I added my route code maybe you can take a look once again?
– Virtual Device
Mar 26 at 16:31
add a comment |
You have 2 good options:
return redirect('/edit');
return view('your.view');
Either should be able to accomplish what you're trying to do.
Actually, you have one realistic option because, IIRC, just callingview
won't fire the corresponding controller, it'll just show the view.
– Script47
Mar 26 at 16:16
Return view seems like a good idea but still doesn't work.
– Virtual Device
Mar 26 at 16:32
add a comment |
Alright! It seems like laravel doesn't see the return from other functions rather than predefined by itself.
So the solution, in that case, would be making the return from within the update method
public function update(Request $request, $id)
return ($request['method']==true) ? $this->imageDelete($request, $id) : null;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361671%2fhow-to-redirect-back-to-edit-page-from-a-called-function%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Just use the route
helper with the redirect
helper to specify the route name you wish to go to:
return redirect()->route('your.route.name');
Note: This requires you to have named your route e.g.
Route::get('/test', 'SomeController@index')->name('test')
or you can pass the URL directly to redirect
.
I've generally found that being explicit in what I want my code to do prevents mistakes / unintended side-effects down the line.
Although in the first place, I posted withback()
method, I usually use this approach in my routing. Unfortunately, it doesn't work. I added my route code maybe you can take a look once again?
– Virtual Device
Mar 26 at 16:31
add a comment |
Just use the route
helper with the redirect
helper to specify the route name you wish to go to:
return redirect()->route('your.route.name');
Note: This requires you to have named your route e.g.
Route::get('/test', 'SomeController@index')->name('test')
or you can pass the URL directly to redirect
.
I've generally found that being explicit in what I want my code to do prevents mistakes / unintended side-effects down the line.
Although in the first place, I posted withback()
method, I usually use this approach in my routing. Unfortunately, it doesn't work. I added my route code maybe you can take a look once again?
– Virtual Device
Mar 26 at 16:31
add a comment |
Just use the route
helper with the redirect
helper to specify the route name you wish to go to:
return redirect()->route('your.route.name');
Note: This requires you to have named your route e.g.
Route::get('/test', 'SomeController@index')->name('test')
or you can pass the URL directly to redirect
.
I've generally found that being explicit in what I want my code to do prevents mistakes / unintended side-effects down the line.
Just use the route
helper with the redirect
helper to specify the route name you wish to go to:
return redirect()->route('your.route.name');
Note: This requires you to have named your route e.g.
Route::get('/test', 'SomeController@index')->name('test')
or you can pass the URL directly to redirect
.
I've generally found that being explicit in what I want my code to do prevents mistakes / unintended side-effects down the line.
answered Mar 26 at 16:13
Script47Script47
10.4k4 gold badges27 silver badges50 bronze badges
10.4k4 gold badges27 silver badges50 bronze badges
Although in the first place, I posted withback()
method, I usually use this approach in my routing. Unfortunately, it doesn't work. I added my route code maybe you can take a look once again?
– Virtual Device
Mar 26 at 16:31
add a comment |
Although in the first place, I posted withback()
method, I usually use this approach in my routing. Unfortunately, it doesn't work. I added my route code maybe you can take a look once again?
– Virtual Device
Mar 26 at 16:31
Although in the first place, I posted with
back()
method, I usually use this approach in my routing. Unfortunately, it doesn't work. I added my route code maybe you can take a look once again?– Virtual Device
Mar 26 at 16:31
Although in the first place, I posted with
back()
method, I usually use this approach in my routing. Unfortunately, it doesn't work. I added my route code maybe you can take a look once again?– Virtual Device
Mar 26 at 16:31
add a comment |
You have 2 good options:
return redirect('/edit');
return view('your.view');
Either should be able to accomplish what you're trying to do.
Actually, you have one realistic option because, IIRC, just callingview
won't fire the corresponding controller, it'll just show the view.
– Script47
Mar 26 at 16:16
Return view seems like a good idea but still doesn't work.
– Virtual Device
Mar 26 at 16:32
add a comment |
You have 2 good options:
return redirect('/edit');
return view('your.view');
Either should be able to accomplish what you're trying to do.
Actually, you have one realistic option because, IIRC, just callingview
won't fire the corresponding controller, it'll just show the view.
– Script47
Mar 26 at 16:16
Return view seems like a good idea but still doesn't work.
– Virtual Device
Mar 26 at 16:32
add a comment |
You have 2 good options:
return redirect('/edit');
return view('your.view');
Either should be able to accomplish what you're trying to do.
You have 2 good options:
return redirect('/edit');
return view('your.view');
Either should be able to accomplish what you're trying to do.
answered Mar 26 at 16:15
LulceltechLulceltech
1,2913 silver badges14 bronze badges
1,2913 silver badges14 bronze badges
Actually, you have one realistic option because, IIRC, just callingview
won't fire the corresponding controller, it'll just show the view.
– Script47
Mar 26 at 16:16
Return view seems like a good idea but still doesn't work.
– Virtual Device
Mar 26 at 16:32
add a comment |
Actually, you have one realistic option because, IIRC, just callingview
won't fire the corresponding controller, it'll just show the view.
– Script47
Mar 26 at 16:16
Return view seems like a good idea but still doesn't work.
– Virtual Device
Mar 26 at 16:32
Actually, you have one realistic option because, IIRC, just calling
view
won't fire the corresponding controller, it'll just show the view.– Script47
Mar 26 at 16:16
Actually, you have one realistic option because, IIRC, just calling
view
won't fire the corresponding controller, it'll just show the view.– Script47
Mar 26 at 16:16
Return view seems like a good idea but still doesn't work.
– Virtual Device
Mar 26 at 16:32
Return view seems like a good idea but still doesn't work.
– Virtual Device
Mar 26 at 16:32
add a comment |
Alright! It seems like laravel doesn't see the return from other functions rather than predefined by itself.
So the solution, in that case, would be making the return from within the update method
public function update(Request $request, $id)
return ($request['method']==true) ? $this->imageDelete($request, $id) : null;
add a comment |
Alright! It seems like laravel doesn't see the return from other functions rather than predefined by itself.
So the solution, in that case, would be making the return from within the update method
public function update(Request $request, $id)
return ($request['method']==true) ? $this->imageDelete($request, $id) : null;
add a comment |
Alright! It seems like laravel doesn't see the return from other functions rather than predefined by itself.
So the solution, in that case, would be making the return from within the update method
public function update(Request $request, $id)
return ($request['method']==true) ? $this->imageDelete($request, $id) : null;
Alright! It seems like laravel doesn't see the return from other functions rather than predefined by itself.
So the solution, in that case, would be making the return from within the update method
public function update(Request $request, $id)
return ($request['method']==true) ? $this->imageDelete($request, $id) : null;
answered Mar 26 at 16:59
Virtual DeviceVirtual Device
791 silver badge9 bronze badges
791 silver badge9 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361671%2fhow-to-redirect-back-to-edit-page-from-a-called-function%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown