technote / laravel-crud-helper
CRUD helper for laravel
Fund package maintenance!
paypal.me/technote0space
Installs: 2 373
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 6
Requires
- php: ^7.4|^8.0
- doctrine/dbal: ^3.2
- laravel/framework: *
Requires (Dev)
- codedungeon/phpunit-result-printer: ^0.32.0
- dealerdirect/phpcodesniffer-composer-installer: ^0.7.2
- fakerphp/faker: ^1.19
- orchestra/testbench: ^6.24
- phpmd/phpmd: ^2.12
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
- technote/laravel-search-helper: ^0.2.27
- dev-main
- v0.2.32
- v0.2.31
- v0.2.30
- v0.2.29
- v0.2.28
- v0.2.27
- v0.2.26
- v0.2.25
- v0.2.24
- v0.2.23
- v0.2.22
- v0.2.21
- v0.2.20
- v0.2.19
- v0.2.18
- v0.2.17
- v0.2.16
- v0.2.15
- v0.2.14
- v0.2.13
- v0.2.12
- v0.2.11
- v0.2.10
- v0.2.9
- v0.2.8
- v0.2.7
- v0.2.6
- v0.2.5
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- v0.0.7
- v0.0.6
- v0.0.5
- v0.0.4
- v0.0.3
- v0.0.2
- v0.0.1
- dev-dependabot/composer/guzzlehttp/psr7-2.5.0
- dev-dependabot/composer/symfony/http-kernel-5.4.20
- dev-release/next-v0.2.32
- dev-dependabot/composer/phpunit/phpunit-9.5.8
- dev-dependabot/composer/codedungeon/phpunit-result-printer-0.31.0
- dev-dependabot/composer/laravel/framework-8.52.0
- dev-dependabot/composer/phpmd/phpmd-2.10.2
- dev-dependabot/composer/fakerphp/faker-1.15.0
- dev-dependabot/composer/orchestra/testbench-6.19.0
- dev-dependabot/composer/league/flysystem-1.1.4
- dev-dependabot/composer/doctrine/dbal-3.1.1
- dev-dependabot/add-v2-config-file
This package is auto-updated.
Last update: 2024-11-19 23:25:54 UTC
README
Read this in other languages: English, 日本語.
CRUD helper for Laravel.
Table of Contents
Details
Install
composer require technote/laravel-crud-helper
Usage
-
Implement
Crudable Contract
andCrudable 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