Hello everyone,
I want to create a small and simple cms for my own website.
Now I am catching the slug and want to check if the page exists in the database.
If so load the page using the PageController.
I want to check if the page exist and if the page is published.
How could I do this nice ?
Here is my code :
class MasterPageController {
/**
* Got the idea from October.
*
* Check out : https://github.com/octobercms/october/blob/master/modules/cms/classes/CmsController.php#L45
*
* @param PagesController $controller
* @param string $url
* @return mixed
*/
public function run(PagesController $controller, $url = '/'){
return $controller->runRoute($url);
}
}
class PagesController extends Controller
{
public function runRoute($route)
{
$page = App\Pages::where('slug', '=', 100)->firstOrFail(); // <<-- How to improve this correct.
}
}