ycs77 / laravel-wizard

A web Setup Wizard for Laravel application.
MIT License
121 stars 18 forks source link

Set done redirect route #22

Closed mikev032 closed 4 years ago

mikev032 commented 4 years ago

Is your feature request related to a problem? Please describe. Would be awesome if we would be able to set a redirect route when the wizard is done: In your controller protected $redirectRoute = route('my-route')

Describe the solution you'd like Make it possible we can redirect if not already exist

Right now I can extend the trait and overwrite the getActionUrl() and check if the method = 'done' but it feels a bit funny

ycs77 commented 4 years ago

For example:

Wizard::routes('wizard/user', 'UserWizardController', 'wizard.user', [
    'done_url' => 'new_done',
]);

The new done url is /wizard/user/new_done.

mikev032 commented 4 years ago

Try it yourself, define a named route like so:

Route::get('/', 'HomeController@index')->name('home'); Wizard::routes('{User}/wizard/user', 'Wizards\UserWizard', 'wizard.user, [ 'done_url' => route('home'), ]);

It also don't work with the redirect() element

If I am correct understanding we only allow hard coded url?

ycs77 commented 4 years ago

This is the case now.

I add it to the todo list.

ycs77 commented 4 years ago

I later thought of another solution, in the WizardController's done method redirect to another URL:

<?php

...
use Ycs77\LaravelWizard\Wizardable;

class UserWizardController
{
    use Wizardable;

    public function done()
    {
        return redirect()->route('home');
    }
}

There is no need to set 'done_url' attribute for Wizard::routes.

mikev032 commented 4 years ago

Ok Ill give it a shot later, I keep you updated 👍