Laravel find page query [need some help]

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.
    }
}

http://laravel.com/docs/5.1/errors#http-exceptions

Thanks for the link.
I also figured it out already.

I made a scope for my query.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.