The Laravel CRUD Generator is a command-line tool designed to streamline the process of creating CRUD (Create, Read, Update, Delete) operations for your Laravel-based RESTful API. It automates the generation of actions, routes, and resources, allowing you to quickly set up endpoints for managing your application's data models.
You can install the package via composer:
composer require mrcookie/simple-api-crud-generator
php artisan api-crud:generate [App/Models/User or User or user]
and then you will get this routes with the related actions so you can customize everything to your needs:
Route::name('users.')->prefix('users')->group(function () {
Route::get('', App\Api\Actions\Users\GetUsersAction::class);
Route::get('{id}', App\Api\Actions\Users\ShowUserAction::class);
Route::put('{id}', App\Api\Actions\Users\UpdateUserAction::class);
Route::delete('{id}', App\Api\Actions\Users\DeleteUserAction::class);
});
Im using "spatie/laravel-query-builder": "^5.3"
to handle query and filtering. u can see "spatie/laravel-query-builder": "^5.3"
https://spatie.be/docs/laravel-query-builder/v5/introduction
You can specified allowedFilters
and allowedFields
in your model
Example
class User extends Model {
public static array $allowedFilters = [
'name'
];
public static array $allowedFields = [
'name'
];
}
-
this Package Uses Laravel Actions for the crud operations
-
this Package Uses Scramble To Generate API Documentation
Scramble Docs
visit [http://localhost:8000/docs/api] to see the generated docs api routes
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.