Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Controllers

William edited this page Mar 20, 2016 · 2 revisions

Create a controller for every Model you want full CRUD access to. If you are just using a Model for relations you can use the include feature to avoid having to make a controller for those models.

$model is the base Model for this controller, in our case we want CRUD on the users table.

$version is an optional variable to allow version control.

<?php

namespace App\Http\Controllers\Api;

use Illuminate\Routing\Controller as BaseController;

class UserController extends BaseController
{

    use \Askedio\Laravel5ApiController\Traits\ControllerTrait;

    /* Base Modal */
    public $model = \App\User::class;

    /* Optional */
    public $version = 'v1';

}

The ControllerTrait will automatically enable all of the API resource functions, this will automatically generate results based upon your Model configuration.

Clone this wiki locally