定制 lupennat/preview 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lupennat/preview

最新稳定版本:v1.0.0

Composer 安装命令:

composer require lupennat/preview

包简介

Laravel Nova - Preview Field

README 文档

README

  1. Requirements
  2. Installation
  3. Usage
    1. When Method
    2. Is Method

Requirements

  • php: ^7.4 | ^8
  • laravel/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
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固