dev-master
9999999-devMy first Composer project
The Requires
- php >=7.0
- laravel/framework >=5.4
by Marco Augusto
dev-concept
dev-conceptMy first Composer project
The Requires
- php >=7.0
- laravel/framework 5.4
by Marco Augusto
Wallogit.com
2017 © Pedro Peláez
My first Composer project
Easy way to produce a highly customisable way to create an basic CRUD Api., (*1)
This are the basics components of the Crud., (*2)
Step 1: Create an Entity, (*3)
In order to store something create an Entity, something around this lines., (*4)
<?php
class Foo implements EntityInterface{}
This will make the Entity recognizeble by all the other methods. If you're using Elloquent there's already an wrapper that will implements all necessaries methods EloquentWarper\Model, (*5)
Step 2: Create the Validations It follows the Laravel Validator ways see more at -https://laravel.com/docs/5.4/validation, (*6)
Example:, (*7)
<?php
class FooValdiator extends ValidatorAbstract
{
public function createRules()
{
return [
'boo' => 'required'
];
}
public function createMessages()
{
return [];
}
}
Step 3:, (*8)
Create some endpoits and implement the Controlify Trait, (*9)
Example:, (*10)
<?php
namespace App\Http\Controllers\Api\V1;
use UnmBtg\Controllers\ControllerInterface;
use UnmBtg\Controllers\Controllify;
use UnmBtg\Entities\EntityInterface;
use UnmBtg\Services\DefaultService;
class FooController extends Controller implements ControllerInterface
{
use Controllify;
protected $validatorException = ValidateException::class;
protected $serviceClass = DefaultService::class;
/**
* @var EntityInterface
*/
protected $entity;
public function __construct()
{
\App::setLocale("pt_br");
$this->service = new $this->serviceClass(new $this->entity);
}
public function index(Request $request) {
return $this->indexRequest($request->all());
}
public function store(Request $request)
{
return $this->storeRequest($request->all());
}
public function update($id, Request $request)
{
return $this->updateRequest($id, $request->all());
}
public function destroy($id) {
return $this->deleteRequest($id);
}
public function show($id) {
return $this->showRequest($id);
}
}
My first Composer project
My first Composer project