digitalcloud/nova-resource-status
Composer 安装命令:
composer require digitalcloud/nova-resource-status
包简介
A Laravel Nova Resource Status.
README 文档
README
A laravel Nova package which allows you to track the status of your Nova resource.
Installation
You can install the package via composer:
composer require digitalcloud/nova-resource-status
You must publish the migrations file:
php artisan vendor:publish --provider="DigitalCloud\NovaResourceStatus\ToolServiceProvider" --tag=migrations
Then, migrate the database table:
php artisan migrate
Optionally, you can publish the config file:
php artisan vendor:publish --provider="DigitalCloud\NovaResourceStatus\ToolServiceProvider" --tag=config
This is the contents of the file which will be published at config/nova-resource-status.php
<?php return [ /* * The class name of the status model that holds all statuses. * The model must be or extend `DigitalCloud\NovaResourceStatus\Models\Status`. */ 'status_model' => DigitalCloud\NovaResourceStatus\Models\Status::class, /* * The default name of the status attribute if not declared in model. */ 'status-field' => 'status' ];
Usage
You must add HasStatus trait to the resource model.
use DigitalCloud\NovaResourceStatus\HasStatus; class YourEloquentModel extends Model { use HasStatus; // use this function to indicate the status column in this model. // If this function not existed, then the value of `status-field` // form config file will be considered. public function statusField() { return 'yourStatusColumn'; } }
This will add database record each time the status attribute changes.
To show all status log, add the Statuses field in your nova resource:
<?php namespace App\Nova; use DigitalCloud\NovaResourceStatus\Fields\Statuses; use Illuminate\Http\Request; class YourResource extends Resource { // ... public static $model = 'YourEloquentModel'; // model must use `HasStatus` trait` public function fields(Request $request) { return [ // ... // This will appear in the resource detail view. Statuses::make(), // ... ]; } // ... }
Then, in resource detail page, you can see the history of your resource status.
Images
统计信息
- 总下载量: 8.11k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-29