technote/laravel-crud-helper
Laravel CRUD Helper
Read this in other languages: English, 日本語.
CRUD helper for Laravel.
Table of Contents
Install
composer require technote/laravel-crud-helper
Usage
-
Implement
Crudable ContractandCrudable Trait.<?php namespace App\Models; use Eloquent; use Illuminate\Database\Eloquent\Model; use Technote\CrudHelper\Models\Contracts\Crudable as CrudableContract; use Technote\CrudHelper\Models\Traits\Crudable; /** * Class Item * @mixin Eloquent */ class Item extends Model implements CrudableContract { use Crudable; /** * @var array */ protected $guarded = [ 'id', ]; }
Routes
CRUD routes are set automatically.
> php artisan route:clear
> php artisan route:list
+--------+-----------+------------------+---------------+-----------------------------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+------------------+---------------+-----------------------------------------------------------------+------------+
| | GET|HEAD | api/items | items.index | Technote\CrudHelper\Http\Controllers\Api\CrudController@index | api |
| | POST | api/items | items.store | Technote\CrudHelper\Http\Controllers\Api\CrudController@store | api |
| | GET|HEAD | api/items/{item} | items.show | Technote\CrudHelper\Http\Controllers\Api\CrudController@show | api |
| | PUT|PATCH | api/items/{item} | items.update | Technote\CrudHelper\Http\Controllers\Api\CrudController@update | api |
| | DELETE | api/items/{item} | items.destroy | Technote\CrudHelper\Http\Controllers\Api\CrudController@destroy | api |
+--------+-----------+------------------+---------------+-----------------------------------------------------------------+------------+
Details
Validation
Some validation rules are generated by column settings automatically.
- Type
- integer
- boolean
- numeric
- date
- time
- string
- Length
- Unsigned
- Nullable
- by column name
- url
- phone
Model name
The model name used is determined by api name.
ex. test_items
- to singular:
test_item - to studly:
TestItem
=> TestItem
Config
Namespace
'App\\Models'- This library does not search recursively.
Prefix
'api'
Middleware
['api']
To Change
-
Run command to generate
config/crud-helper.php.php artisan vendor:publish --provider="Technote\CrudHelper\Providers\CrudHelperServiceProvider" --tag=config -
Edit settings.
'namespace' => 'App\\Models\\Crud', 'prefix' => 'api/v1', 'middleware' => [ 'api', 'auth', ],
Search feature
If implement Searchable, you can add search feature.
Laravel Search Helper
api/items?s=keyword
Author
Related Packages
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v0.2.32 | ^7.4| | * | MIT | |
| v0.2.31 | ^7.4| | * | MIT | |
| v0.2.30 | ^7.4| | * | MIT | |
| v0.2.29 | ^7.4| | * | MIT | |
| v0.2.28 | ^7.4| | * | MIT | |
| v0.2.27 | ^7.4| | * | MIT | |
| v0.2.26 | ^7.4| | * | MIT | |
| v0.2.25 | ^7.4| | * | MIT | |
| v0.2.24 | ^7.4| | * | MIT | |
| v0.2.23 | ^7.4| | * | MIT | |
| v0.2.22 | ^7.4| | * | MIT | |
| v0.2.21 | ^7.3| | * | MIT | |
| v0.2.20 | ^7.3| | * | MIT | |
| v0.2.19 | ^7.3| | * | MIT | |
| v0.2.18 | ^7.3 | * | MIT | |
| v0.2.17 | ^7.3 | * | MIT | |
| v0.2.16 | ^7.3 | * | MIT | |
| v0.2.15 | ^7.3 | * | MIT | |
| v0.2.14 | ^7.3 | * | MIT | |
| v0.2.13 | ^7.3 | * | MIT | |
| v0.2.12 | ^7.3 | * | MIT | |
| v0.2.11 | ^7.3 | * | MIT | |
| v0.2.10 | ^7.3 | * | MIT | |
| v0.2.9 | ^7.3 | * | MIT | |
| v0.2.8 | ^7.3 | * | MIT | |
| v0.2.7 | ^7.3 | * | MIT | |
| v0.2.6 | ^7.3 | * | MIT | |
| v0.2.5 | ^7.3 | * | MIT | |
| v0.2.4 | ^7.3 | * | MIT | |
| v0.2.3 | ^7.3 | * | MIT |
Showing the latest 30 of 46. See every release on Packagist