C
C
chelkaz2016-03-12 02:57:50
Laravel
chelkaz, 2016-03-12 02:57:50

Router In Laravel Is that right?

There is a route that only an authorized user can go through.
But there are also routes for all users.
That is, in create only authorized, it was possible to do something like this. But is it true?
Route::resource('/adboard', 'AdboardController',
['only' => ['index', 'store', 'show', 'create']]);
Route::get('/adboard/create', [
'middleware' => 'auth',
'uses' => '[email protected]'
]);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2016-03-12
@chelkaz

In the controller in __construct you can do:

function __construct() {
  $this->middleware('auth', ['only' => ['create', 'store']]);
}

And then you can just do:
$router->resource('adboard', 'AdboardController');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question