lundi 24 septembre 2018

Laravel route [login] not defined inside a file

I am building a modular application in laravel. I created a User module and here is the routes:

<?php
Route::group(['middleware' => 'web', 'namespace' => 'Modules\User\Http\Controllers'], function()
{
    Route::get('/', 'UserController@index');
    Route::get('login', 'LoginController@showLoginForm')->name('login');
    Route::post('login', 'LoginController@login');
    Route::post('logout', 'LoginController@logout')->name('logout');
});
Route::group(['middleware' => 'admin', 'prefix' => 'user', 'namespace' => 'Modules\User\Http\Controllers'], function()
{
    Route::get('register', 'RegisterController@showRegistrationForm')->name('register');
    Route::post('register', 'RegisterController@register');
});

The route('login') statement returns the url to login page and it works well. Inside the config.php I need to access this function as follows

<?php

return [
    'name' => 'User',
    'menu' => [
        'weight' => 1,
        'item'  => [
            'Login' => [route('login'), 'guest'],
            'Register' => [route('register'), 'guest'],
        ]
    ]
];

Inside this file the error Route [login] not defined. is reported. Why is this undefined in there?

I also tried adding the following line

namespace Modules\User\Http\Controllers;

But it still not working

thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire