By all means experiment with different ways, I don't think theres any right/wrong answers when it comes to questions like this one. I would go about creating a PagesController and an ArchiveController.
// routes.php
// Static Pages
Route::get('/', ['as' => 'home', 'uses' => 'PagesController@showLandingPage']);
Route::get('/about', 'as' => 'about', 'uses' => 'PagesController@showAboutUsPage']);
// Archives
Route::get('/archives', ['as' => 'list-archives', 'uses' => 'ArchiveController@listRecentArchives']);
Route::get('/archives/topic/{slug}', ['as' => 'browse-by-topic', 'uses' => 'ArchiveController@browseByTopic']);
Route::get('/archives/date/{date}', ['as' => 'list-archives', 'browse-by-date' => 'ArchiveController@browseByDate']);
// PagesController.php
class PagesController extends BaseController {
public function showLandingPage()
{
return View::make('static.home');
}
public function showAboutUsPage()
{
return View::make('static.about');
}
}
// ArchivesController.php
class ArchivesController extends BaseController {
public function listRecentArchives()
{
// Get recent archives from wherever they are stored
$archives = [];
return View::make('archives.index')->withArchives($archives);
}
public function browseByTopic($slug)
{
// Get archives from wherever stored using the topic slug
$archives = [];
return View::make('archives.browse')->withArchives($archives);
}
public function browseByDate($date)
{
// Get archives from wherever stored using the date provided
$archives = [];
return View::make('archives.browse')->withArchives($archives);
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community