Reputation: 786
I am newbie to laravel. I created new controller - book. This is my code -
class BookController extends BaseController {
public function index()
{
return View::make('book.index');
}
public function insert()
{
return View::make('book.insert');
}
}
My routes.php -
Route::get('book/', 'BookController@index');
//Route::any('book/insert', array('uses' => 'BookController@insert'));
When i uncomment 2nd line, i can access insert page. Is it possible to access pages without add them to routes.
Now it produce this error
Upvotes: 1
Views: 5505
Reputation: 6438
You may read about resource controller.
Execute this on terminal:
php artisan make:controller BookController
This command will generate BookController.php
in your app/controllers
folder. Read the code for more information.
Define in your routes/web.php
file:
Route::resource('book', 'BookController');
Actions Handled By Resource Controller:
Upvotes: 4
Reputation: 2347
Route filters provide a convenient way of limiting access to a given route, which is useful for creating areas of your site which require authentication. So it is better to use route.php as Laravel framework indicates. you can add filters to there as well, refer documentation
Upvotes: 0