定制 mmerlijn/nova-checkboxes-field 二次开发

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

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

mmerlijn/nova-checkboxes-field

最新稳定版本:v5.2

Composer 安装命令:

composer require mmerlijn/nova-checkboxes-field

包简介

A Laravel Nova field.

README 文档

README

install

composer require mmerlijn/nova-checkboxes-field

Usage

use \mmerlijn\NovaCheckboxesField\Checkboxes;

Checkboxes::make('Roles')->options([
    1 => 'Admin',
    2=> 'Super user',
]);

config

You can customise how the values from checkbox fields are passed to your scripts. By default it's will cast all numeric keys to floats or integers, e.g. [1, 2, 3] instead of ["1", "2", "3"]. You can save disable this feature by calling withoutTypeCasting() to have the original array keys returned unmodified.

Checkboxes::make('Permissions')->options([
    1 => 'Access Admin UI',
    2 => 'Manage Users',
])->withoutTypeCasting(),

Example

Checkboxes::make('users')
    ->options(App\User::pluck('name', 'id'))
    ->withoutTypeCasting(),

Give permissions to user

Add to fields

Checkboxes::make('Permissions','permissionArray') 
    ->options(Permission::pluck('name', 'id')->toArray())
    ->hideFromIndex(),

Add to User model

public function setPermissionArrayAttribute(array $value)
{
    $this->permissions()->sync($value);
}
public function getPermissionArrayAttribute()
{
    return $this->permissions->map(fn($item) => $item->pivot->permission_id)->toArray();
}

Only for developing

Make changes after nova update

cd vendor/laravel/nova && npm install

Credits to

Silvanite

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-18