Last active
December 23, 2015 11:38
-
-
Save thelinuxlich/6629372 to your computer and use it in GitHub Desktop.
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 | |
class RoleController extends BaseController { | |
public function getIndex() | |
{ | |
return Response::json(Role::all()); | |
} | |
public function postCreate() | |
{ | |
return $this->save(new Role); | |
} | |
public function getShow($id) | |
{ | |
return Response::json(Role::find($id)); | |
} | |
public function save($obj) { | |
try { | |
$obj->fill(Input::all())->save(); | |
return Response::json(array("status" => true,"msg" => "Nível gravado com sucesso.")); | |
} catch(Exception $e) { | |
return Response::json(array("status" => false,"msg" => "Ocorreu um erro ao tentar gravar o nível.")); | |
} | |
} | |
public function postUpdate($id) | |
{ | |
return $this->save(Role::find($id)); | |
} | |
public function postDestroy($id) | |
{ | |
try { | |
Role::destroy($id); | |
return Response::json(array("status" => true)); | |
} catch(Exception $e) { | |
return Response::json(array("status" => false,"msg" => "Não foi possível remover o nível.")); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment