ruskiyos/requlor

Useful wrappers and helper classes for handling requests and responses in Laravel5

dev-master / 1.0.x-dev 2019-12-06 17:38 UTC

This package is not auto-updated.

Last update: 2022-01-16 18:55:07 UTC


README

Request and Response helper classes for Laravel5

Installation

composer require ruskiyos/requlor

Controllers

ApiController

/** @var ApiManager */
protected $manager;

/** @var string[] */
protected $notAllowedActions = [];

/** @var AbstractCriteria[] */
protected static $paramCriteria = [];

/** @var string[]|ApiManager[] */
protected static $parentManagers = [];

/** @var string[]|AbstractCriteria[] */
protected static $parentCriteria = [];

protected function handleIndex(?Request $request, array $parentIds = [])
protected function handleCreate(?Request $request, array $parentIds = [])
protected function handleShow(?Request $request, $id, array $parentIds = [])
protected function handleUpdate(?Request $request, $id, array $parentIds = [])
protected function handleDelete(?Request $request, $id, array $parentIds = [])
protected function buildParentCriteria(?Request $request, array $parentIds = [], ApiAction $action)
protected function interpretId(Request $request, ids, ApiAction $action)

Managers

ApiManager

/** @var string|ApiModel */
protected $modelClass;
/** @var string|AbstractTransformer */
protected $transformerClass;
/** @var string|ApiValidator */
protected $validatorClass;

/** @var boolean */
private $isOwnable;
/** @var ApiValidator */
private $validator;

abstract protected function canAction($action): bool;
abstract protected function getActionValue($action): bool;

public function index(Criterion $criterion = null)
public function create(array $data, Criterion $criterion = null)
public function show($id, Criterion $criterion = null)
public function update($id, array $data, Criterion $criterion = null)
public function delete($id, Criterion $criterion = null)

protected function getRequestId()

public function canIndex(Criterion $criterion = null)
public function canCreate(array $data = [], Criterion $criterion = null)
public function canShow($id, Criterion $criterion = null)
public function canUpdate($id, array $data = [], Criterion $criterion = null)
public function canDelete($id, Criterion $criterion = null)

protected function preIndex(Criterion $criterion)
protected function preCreate(array &$data, Criterion $criterion)
protected function preShow($id, Criterion $criterion)
protected function preUpdate($id, array &$data, Criterion $criterion, ApiModel $model)
protected function preDelete($id, Criterion $criterion, ApiModel $model)

protected function verifyOwnalbe($id = null)