My problem is concerned with:
a blog homepage called via the ArticlesController@index function
the individual blog post pages called via ArticlesController@show function, and
the comment form to be embedded into the individual blog post pages that would post to blog/{blog}/comment and would invoke the CommentsController@store method
I have the following routes of concern defined in my routes.php file:
Route::resource ('blog', 'ArticlesController');
Route::resource ('blog/{blog}/comment', 'CommentsController');
The ArticlesController is set to call the auth middleware for all functions except index() and show($id):
public function __construct()
{
$this->middleware('auth', ['except' => 'index', 'show']);
}
When I attempt to access the individual blog post pages without the comment form, it works as expected and allows me to access the homepage and individual post pages without authentication.
Whereas when I have the comment form embedded into the individual post pages, it allows me to access the homepage but demands me to authenticate before I could access the individual post pages.
Can anyone tell me why it behaves so even though my CommentsController is a separate entity and it is not invoking the auth middleware?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire