-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
236 additions
and
146 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php use Augusthur\Validation as Validate; | ||
|
||
class OrganismoCtrl extends RMRController { | ||
|
||
protected $mediaTypes = array('json'); | ||
protected $properties = array('id', 'nombre', 'cupo', 'funcionarios_count'); | ||
|
||
public function queryModel() { | ||
return Organismo::query(); | ||
} | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php use Augusthur\Validation as Validate; | ||
|
||
abstract class RMRController extends Controller { | ||
|
||
protected $mediaTypes = array(); | ||
protected $properties = array(); | ||
|
||
abstract public function queryModel(); | ||
|
||
public function listar() { | ||
$req = $this->request; | ||
$repr = $this->negotiateContent($req->headers->get('ACCEPT')); | ||
$queryMaker = new QueryMaker($this->queryModel(), $req->get()); | ||
$queryMaker->addFilters($this->properties); | ||
$queryMaker->addSorters($this->properties); | ||
$url = $req->getUrl().$req->getPath(); | ||
$paginator = new Paginator($queryMaker->query, $url, $queryMaker->params); | ||
$repr->shwCollection($this, $paginator); | ||
} | ||
|
||
public function ver($id) { | ||
$req = $this->request; | ||
$repr = $this->negotiateContent($req->headers->get('ACCEPT')); | ||
$vdt = new Validate\QuickValidator(array($this, 'notFound')); | ||
$vdt->test($id, new Validate\Rule\NumNatural()); | ||
$resource = $this->queryModel()->findOrFail($id); | ||
$repr->shwResource($this, $resource); | ||
} | ||
|
||
public function negotiateContent($accept) { | ||
if (substr($accept, 0, 16) == 'application/json') { | ||
$this->response->headers->set('Content-Type', 'application/json; charset=UTF-8'); | ||
$this->api = true; | ||
$repr = new JsonRepr(); | ||
} else { | ||
$repr = new ViewRepr(); | ||
} | ||
if (!in_array($repr->getName(), $this->mediaTypes)) { | ||
throw new BearableException('Petición de formato de contenido no disponible.', 406); | ||
} | ||
return $repr; | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php use Illuminate\Database\Eloquent\Model as Eloquent; | ||
|
||
class Poder extends Eloquent { | ||
|
||
protected $table = 'poderes'; | ||
protected $visible = array('id', 'accion', 'patrulla_id', 'created_at', 'updated_at'); | ||
|
||
public function patrulla() { | ||
return $this->belongsTo('Patrulla'); | ||
} | ||
|
||
} |
Oops, something went wrong.