定制 wtfz/laravel-route-button 二次开发

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

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

wtfz/laravel-route-button

最新稳定版本:v1.1.1

Composer 安装命令:

composer require wtfz/laravel-route-button

包简介

Generate route buttons with dropdown from the model

README 文档

README

Latest Version on Packagist Total Downloads License

Generate route buttons with dropdown from the model.

Installation

composer require wtfz/laravel-route-button

Customization

To customize, publish and edit the component.

php artisan vendor:publish --tag=laravel-route-button
// resources/views/vendor/route-button

Usage

Add this code and define each route buttons inside your model.

use Wtfz\LaravelRouteButton\RouteButton;

class YourModel extends Model
{
    use RouteButton;

    // init empty route button
    public static $routeButton = [];

    // or init global route button
    public static $routeButton = [
            [
                'route' => 'admin.auth.user.delete',
                'text' => 'Delete User',
                'view' => 'frontend.profile.confirm',
                'args' => [$this, 1], // Optional, default: $model
            ],
            // ...
        ];

    // or init named route button
    public static $routeButton = [
            'index' => [
                'route' => 'admin.auth.user.edit',
                'text' => 'Edit User'
            ],
            'edit' => [
                'route' => 'admin.auth.user.destroy',
                'text' => 'Destroy User'
            ],
            // ...
        ];

    // or init mixed route button
    public static $routeButton = [
            [
                'route' => 'admin.auth.user.edit',
                'text' => 'Edit User',
                'args' => [$this, 1], // Optional, default: $model
            ],
            'index' => [
                'route' => 'admin.auth.user.edit',
                'text' => 'Edit User'
            ],
            'edit' => [
                'route' => 'admin.auth.user.destroy',
                'text' => 'Destroy User'
            ],
            // ...
        ];
}

Render route button inside your view by calling it from your model.

// global route button
{{ $model->routeButton() }}

// named route button
{{ $model->routeButton('edit') }}

// or in Livewire table...
Column::make(__('Actions'), 'id')
    ->format(function ($value, $row, $column) {
        return $row->routeButton('edit');
    }),

// or add new route button on the fly...
Column::make(__('Actions'), 'id')
    ->format(function ($value, $row, $column) {
        // for global route (set integer index)
        $row::$routeButton[0][] = [
            'route' => 'admin.auth.user.delete',
            'text' => 'Delete User',
            'args' => ['type' => 'member', 'user' => $row],
        ];

        // for named route (set string index)
        $row::$routeButton['edit'][] = [
            'route' => 'admin.auth.user.delete',
            'text' => 'Delete User',
            'args' => ['type' => 'member', 'user' => $row],
        ];

        return $row->routeButton('index');
    }),

License

Copyright © Ahmad Zaim

The MIT License (MIT)

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固