Creating Front End Routes for Modules



  • I've created a module and have the following route for the front end of my custom module

    $router->group(['prefix' =>'/brokerquotes'], function (Router $router) {
    $router->bind('request', function ($id) {
            return app('Modules\Brokerquotes\Repositories\RequestRepository')->find($id);
        });
        $router->get('requests', [
            'as' => 'brokerquotes.request.index',
            'uses' => 'RequestController0',
            'middleware' => 'can:brokerquotes.requests.index'
        ]);
        $router->get('requests/create', [
            'as' => 'brokerquotes.request.create',
            'uses' => 'RequestController@create',
            'middleware' => 'can:brokerquotes.requests.create'
        ]);
        $router->post('requests', [
            'as' => 'brokerquotes.request.store',
            'uses' => 'RequestController@store',
            'middleware' => 'can:brokerquotes.requests.create'
        ]);
    

    I have not created any views or pages as yet as I'm just trying to test to see if the routes are working. So when going to /en/brokerquotes/requests/create I am redirected to login.

    The routes defined need to be public so how do I disable the redirect to login for these routes?


  • admin

    Did you add those routes in your backendRoutes.php file? If so that's why it's requesting you to login.

    You need to create a file that will contain frontend routes, and load that file in your RouteServiceProvider in your module. Like here



  • @nwidart said in Creating Front End Routes for Modules:

    Did you add those routes in your backendRoutes.php file? If so that's why it's requesting you to login.

    You need to create a file that will contain frontend routes, and load that file in your RouteServiceProvider in your module. Like here

    I added this to the frontendRoute file and updated the ServiceProvider. It works now


Log in to reply
 

Looks like your connection to AsgardCms was lost, please wait while we try to reconnect.