mrcookie / simple-api-crud-generator
This is my package simple-api-crud-generator
Requires
- php: ^8.1
- dedoc/scramble: ^0.8.3
- doctrine/dbal: ^3.6
- illuminate/contracts: ^10.0
- lorisleiva/laravel-actions: ^2.7
- spatie/laravel-package-tools: ^1.14.0
- spatie/laravel-query-builder: ^5.3
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
README
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.
Installation
You can install the package via composer:
composer require mrcookie/simple-api-crud-generator
Usage
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' ]; }
Notes
-
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
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.