Created
June 22, 2016 22:17
-
-
Save jjsquady/d359fa6140e7adf7b990ae2b274ed0bd to your computer and use it in GitHub Desktop.
Controller using RestfulApi abstract Class on Laravel 5.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\Cliente; | |
use App\Http\Api\RestfulApi; | |
use App\Http\Requests\ClientRequest; | |
class ClienteController extends RestfulApi | |
{ | |
protected $defaultView = 'clientes.index'; | |
protected $deleteErrorMessage = 'Erro ao excluir cliente.'; | |
protected $deleteSuccessMessage = 'Cliente removido com sucesso.'; | |
protected $invalidIdMessage = 'ID de cliente inválido.'; | |
protected $withRelations = [ | |
'eventos' => ['*'], | |
'eventos.tipoEvento' => ['id', 'nome'], | |
'eventos.salao' => ['id', 'nome'] | |
]; | |
/** | |
* ClienteController constructor. | |
*/ | |
public function __construct(Cliente $cliente) | |
{ | |
$this->model = $cliente; | |
} | |
public function store(ClientRequest $request) | |
{ | |
parent::storeModel($request); | |
} | |
public function update(ClientRequest $request, $id) | |
{ | |
parent::updateModel($request, $id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment