Using Pages In Custom Controllers

You can get some of the benefits of Pages when using a custom controller. These include being able to "unpublish" the route by unpublishing the associated page, and using the page's meta data.

To do this, add the Yadda\Enso\Crud\Traits\UsesPages trait to your controller, then call usePage in your controller method.

<?php

namespace App\Http\Controllers;

use Yadda\Enso\Crud\Traits\UsesPages;

class ThingController extends Controller
{
    use UsesPages;

    /**
     * Show a list of things
     */
    public function index()
    {
        $this->usePage('things');

        return view('things.index');
    }
}