v0.1.0 2020-09-10 05:56 UTC

This package is auto-updated.

Last update: 2022-06-13 10:46:34 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

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.