Releases: phpsa/laravel-api-controller
Releases · phpsa/laravel-api-controller
Removed Dead Code
2.2.1 Update MethodRules.php
Store / update request combine / seperate
- fixes issue where should be returning not-found for items that do not exist
- added new trait
\Phpsa\LaravelApiController\Http\Request\Traits\MethodRules
to allow you to use the same request for different request types
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Phpsa\LaravelApiController\Http\Request\Traits\MethodRules;
class PostRequest extends FormRequest
{
use MethodRules;
/**
* Get the validation rules that apply to all requests.
*
* @return array
*/
public function commonRules()
{
//Only admins can set someone else as a user id
$userIdRule = auth()->user()->hasRole('Admin') ? 'optional' : 'prohibited';
return [
'title' => ['string'],
'description' => ['string'],
'user_id' => ['int',$userIdRule],
'image' => ['nullable'],
'category_id' => ['int', 'nullable'],
'published_at' => ['date', 'nullable'],
];
}
public function storeRules() //called from controller store method
{
return [
'title' => ['string','required'],
'description' => ['string','required'],
];
}
public function updateRules() //called from controller update method
{
return [
'published_at' => ['date','required','nullable'],
];
}
}
Raw Query Fix
Raw Queries where breaking the allowedfields functionality from v1,
This patch restores the rawQuery back to an array instead of an StdClass object when passing to the api resource as was done in V1
BugFix
2.0.0
Upgrading from V1
The only breaking change would be that we no longer use the BaseRepository Class, so any references to it should be switched out for the Eloquent Builder
Changes
- Removed BasedRepository in favour of Eloquent Builder
- Code tidy-up and some traits moved
- new tests implemented
- api make command suite upgraded
- added db macros for
getRaw
,paginateRaw
- added optional validation request trait for formRequest to seperate rules per action.
Supports Laravel 6,7 & 8
Release Candidate - no more breaking changes should now be slipped in.
2.0.0-rc.1 Laravel 6 test case dir not existing for touch
Beta Update
2.0.0-b.3 Some code tidy
Beta Release
-
- Postman method in controller
- Fixes missing
:class
in controller resource properties
2.0.0-a.1
Cli tools updates
cli tools are now more optimised and use more core functionality, also creates factories