lupennat/preview
最新稳定版本:v1.0.0
Composer 安装命令:
composer require lupennat/preview
包简介
Laravel Nova - Preview Field
README 文档
README
Requirements
php: ^7.4 | ^8laravel/nova: ^4
Installation
You can install the package in to a Laravel app that uses Nova via composer:
composer require lupennat/preview
Usage
Preview Field can be used to Display a Detail Field on Index Page in a dropdown (like Nova BooleanGroup Field Behaviour). On Detail Page, the field will be always displayed as native field, on Form pages the Field will not be displayed.
When Method
You can use when method to switch between preview/inline mode at specific condition.
If a string will be returned from callback, the string will be used as text for the dropdown button.
use Illuminate\Support\Str; use Laravel\Nova\Fields\Text; use Laravel\Nova\Http\Requests\NovaRequest; use Lupennat\Preview\Preview; class Post extends Resource { public function fields(Request $request) { return [ Preview::make(__('Title'), 'title')->when( fn($value, $resource, $attribute) => strlen($value) > 20 ? Str::limit($value, 20) : false, Text::make(__('Title'), 'title') ) ]; } }
Is Method
You can use is method to always display a field as preview.
use Laravel\Nova\Fields\Text; use Laravel\Nova\Http\Requests\NovaRequest; use Lupennat\Preview\Preview; class Post extends Resource { public function fields(Request $request) { return [ Preview::make(__('Description'), 'description') ->is(Text::make(__('Description'), 'description')) ->withPreviewLabel(__('View Description')) ]; } }
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-05-22