composer install
php artisan migrate
php artisan scribe:generate
Run the server
php artisan serve
Generated using scribe
URL: /docs
Codes and Routes are using separate folders
- app/Http/Controllers/API/V1
- app/Http/Controllers/API/V2
- routes/api_v1.php
- routes/api_v2.php
Edit config/app.php
and modify
'api_latest' => '1',
You can modify the route api prefix in RouteServiceProvide.php
- Implemented custom handler to send Exception as JSON Response
- Validation Errors are caught and send out as an JSON with a list of errors
- Exception StackTrace are shown if
app.debug
isenabled
See app/Exception/Handler.php
There are two types of data validation
- Resource Data Validation Rules
- Request Parameter Validation
All Controller methods are using FormRequest to validate data before it hits the controller. If it throws an error the API will automatically transform the Exception to a JSON response.
Some methods has controls that uses queryParams and needs to be validated.
Since Laravel's FormRequest class does cannot validate QueryParams, I've added an a code that adds the queryParams to $request->all()
in order for the validation rules to work
see app\Http\Requests\AbstractRequest.php
To separate adding of filters, and sorting to Resources. I've added a class for Searching. It automatically applies all eloquent filters available to the resource
see app\Http\Search\TaskSearch.php
in the controller it will look like this
// apply filters available in the request object
$query = (new TaskSearch)->apply($request);
$data = new TaskCollection($query->paginate(2)->withQueryString());
- All Task are checked if the current logged in user is the owner
See app/Policies/TaskPolicy.php
see spatie/laravel-medialibrary
see spatie/laravel-tags
- INVALID TAGS are not defined
- Improve media and tags CRUD
/task/{task}/tags
/task/{task}/media