DcatAdmin行操作按钮样式调整(图标+文字)

效果

更改方式

app/Admin/Actions/Grid/下新建TextActions.php文件, 内容如下
<?php

namespace App\Admin\Actions\Grid;

use Dcat\Admin\Grid\Displayers\Actions;

/**
 * 重写行操作按钮样式
 */
class TextActions extends Actions
{

    /**
     * @return string
     */
    protected function getViewLabel()
    {
        $label = trans('admin.show');
        return '<i class="feather icon-eye text-success"></i> <span class="text-success">' . $label . '</span> &emsp;';
    }

    /**
     * @return string
     */
    protected function getEditLabel()
    {
        $label = trans('admin.edit');

        return '<i class="feather icon-edit-1 text-custom"></i> <span class="text-custom">' . $label . '</span> &emsp;';
    }

    /**
     * @return string
     */
    protected function getQuickEditLabel()
    {
        $label = trans('admin.edit');
        $label2 = trans('admin.quick_edit');

        return '<i class="feather icon-edit-1 text-custom"></i> <span class="text-custom" title="' . $label2 . '">' . $label . '</span> &emsp;';
    }

    /**
     * @return string
     */
    protected function getDeleteLabel()
    {
        $label = trans('admin.delete');

        return '<i class="feather icon-alert-triangle text-danger"></i> <span class="text-danger">' . $label . '</span> &emsp;';
    }
}
config/admin.php中更改配置项grid.grid_action_class, 如下
// The global Grid action display class.
'grid_action_class'  => App\Admin\Actions\Grid\TextActions::class,

参考文章:  Dcat Admin 修改全局行操作按钮显示方式为文字+图标

本作品采用《CC 协议》,转载必须注明作者和本文链接
啪嗒啪嗒啪嗒 (`・ω・´)つ_▃ <?php echo "PHP is the best language in the world!"; ?>
slowlyo
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 3

细致的功能就是表现出简单、直接 :+1:

2年前 评论
Hpeng

支持

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!