nguyentranchung / rookie
Like Nova but Rookie
Requires
- php: ^7.1
- illuminate/support: ^7.0 || ^8.0
- livewire/livewire: ^2.0
- protonemedia/laravel-form-components: ^1.3
- spatie/laravel-collection-macros: ^7.0
Requires (Dev)
- orchestra/testbench: ^5.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2022-06-13 10:46:34 UTC
README
This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.
Roadmap
- Index view: Chức năng phân trang
- Index view: Chức năng tìm kiếm
- Index view: Chức năng sắp xếp như datatable
- Index view: Thêm các bộ lọc như nova
- Index view: Thêm các actions như nova
- Form: Tự động validate các fields trong forms
- Form: Tự động xử lý store
- Form: Tự động xử lý update
- Form: Tự động xử lý delete
Installation
You can install the package via composer:
composer require nguyentranchung/rookie
Publish config
php artisan vendor:publish --provider=NguyenTranChung\Rookie\RookieServiceProvider
Usage
Tạo files UserRookie.php trong thư mục app\Rookies
<?php namespace App\Rookies; use App\Models\User; use Illuminate\Http\Request; use NguyenTranChung\Rookie\Fields\Field; use NguyenTranChung\Rookie\Fields\HasMany; use NguyenTranChung\Rookie\Fields\MorphTo; use NguyenTranChung\Rookie\Forms\Email; use NguyenTranChung\Rookie\Forms\Password; use NguyenTranChung\Rookie\Forms\Text; use NguyenTranChung\Rookie\Rookie; class UserRookie extends Rookie { protected static string $name = 'users'; protected static string $modelClass = User::class; protected string $title = 'name'; /** * @inheritDoc */ public function fields() { return [ Field::make(User::ID), Field::make(User::NAME) ->search() ->sortable(), Field::make(User::EMAIL) ->search() ->sortable(), MorphTo::make(User::ROLES, RoleRookie::class), MorphTo::make(User::PERMISSIONS, PermissionRookie::class), HasMany::make(User::POSTS, PostRookie::class) ->showCountOnly(), Field::make(User::CREATED_AT) ->setValue(fn(User $model) => $model->created_at->diffForHumans()), ]; } public function forms() { return [ Text::make(User::NAME), Email::make(User::EMAIL), Password::make(User::PASSWORD), Password::make('password_confirmation'), ]; } }
Sau đó thêm vào trong config\rookie.php
<?php return [ // ... 'rookies' => [ App\Rookies\UserRookie::class, ], ];
Mở trình duyệt truy cập http://localhost:8000/rookies/users
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email nguyentranchung52th@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.