asmiarowski / laravel5-api-generator by asmiarowski

Artisan generator for API reasource.
1,753
4
2
Package Data
Maintainer Username: asmiarowski
Maintainer Contact: artur.smiarowski@gmail.com (Artur Śmiarowski)
Package Create Date: 2015-10-24
Package Last Update: 2017-06-04
Language: PHP
License: MIT
Last Refreshed: 2024-12-21 03:01:11
Package Statistics
Total Downloads: 1,753
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 4
Total Watchers: 2
Total Forks: 3
Total Open Issues: 0

laravel5-api-generator

Generates boilerplate for laravel REST API: migration, controller, model, request and route.

composer require --dev asmiarowski/laravel5-api-generator
if ($this->app->environment() == 'local') {
    $this->app->register('Smiarowski\Generators\GeneratorsServiceProvider');
}

For POST / PUT data to work you either have to send your request with Accept: application/json header or set up json responses globally in app/Http/Requests/Request.php like so:

/**
 * Overwrite Laravel Request method because API is always returning json
 * @return bool
 */
public function wantsJson()
{
    return true;
}
php artisan make:api-resource <table_name> --schema="<column_name>:<column_type>(<arguments>):<option>(<arguments>); [...]" --softdeletes
php artisan make:api-resource emails --schema="email:email:unique; title:string; body:text; status:integer:default(1); user_id:integer:foreign(users)" --softdeletes