laravel-admin 在列表页添加自定义按钮

2022-08-15 08:39:11

我的个人博客:逐步前行STEP

为了添加自定义按钮,按官方文档分4步走:
1、先定义工具类app/Admin/Extensions/Tools/ShowArtwork.php:

<?php

namespace App\Admin\Extensions\Tools;

use Encore\Admin\Admin;
use Encore\Admin\Grid\Tools\AbstractTool;
use Illuminate\Support\Facades\Request;

class ShowArtwork extends AbstractTool
{
    protected  $url;
    protected  $icon;
    function __construct($url,$icon,$text)
    {
        $this->url = $url;
        $this->icon = $icon;
        $this->text = $text;
    }

    public function render()
    {
        $url = $this->url;
        $icon = $this->icon;
        $text = $this->text;
        return view('admin.tools.button', compact('url','icon','text'));
    }
}

2、定义试图文件:resources/views/admin/tools/button.blade.php

<div class="btn">
    <a class="b
  • 作者:闲敲代码、落灯花
  • 原文链接:https://blog.csdn.net/hhhzua/article/details/80617454
    更新时间:2022-08-15 08:39:11