mrcookie/simple-api-crud-generator

This is my package simple-api-crud-generator

0.0.1 2023-09-16 23:08 UTC

This package is auto-updated.

Last update: 2024-04-17 00:33:21 UTC


README

Latest Version on Packagist

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.