定制 tunezilla/dynamic-action-fields 二次开发

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

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

tunezilla/dynamic-action-fields

最新稳定版本:v1.0.1

Composer 安装命令:

composer require tunezilla/dynamic-action-fields

包简介

Dynamic Action Fields for Laravel Nova

README 文档

README

This package allows you to change the fields of a Laravel Nova Action depending on which resources are selected.

This is experimental, proceed at your own risk

Screenshot

Screenshot of Dynamic Action Fields

Installation

composer require tunezilla/dynamic-action-fields 

Usage

  1. Add the DynamicFieldAction trait to your resource

  2. Change your public function fields() to public function fieldsForModels(Collection $models): array

Example:

<?php namespace App\Nova\Actions; use App\User; use Illuminate\Support\Collection; use Laravel\Nova\Actions\Action; use Laravel\Nova\Fields\ActionFields; use Laravel\Nova\Fields\Boolean; use Laravel\Nova\Fields\Hidden; use Laravel\Nova\Fields\Text; use TuneZilla\DynamicActionFields\DynamicFieldAction; /**  * Class ChangeEmail  * @package App\Nova\Actions  *  * Example usecase of tunezilla/dynamic-action-fields  */ class ChangeEmail extends Action { use DynamicFieldAction; public function fieldsForModels(Collection $models): array { if ($models->isEmpty()) { return []; } /** @var User $user */ $user = $models->first(); return [ Text::make('Email') ->help('The new email for ' . $user->name), $user->hasVerifiedEmail() ? Boolean::make('Require Verification') ->help('Send a verification email that they must accept') : Hidden::make('Require Verification'), ]; } public function handle(ActionFields $fields, Collection $models) { /** @var User $user */ $user = $models->first(); $user->email = $fields->get('email'); if ($fields->get('require_verification')) { $user->email_verified_at = null; } $user->save(); if (!$user->hasVerifiedEmail()) { $user->sendEmailVerificationNotification(); } return Action::message(implode(' ', [ 'Changed email to ' . $fields->get('email'), $fields->get('require_verification') ? 'and sent a verification email' : 'but did not send a verification email' ])); } }

统计信息

  • 总下载量: 108.02k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 3
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固