laravel nova隐藏索引页面上的编辑按钮 [英] laravel nova hide edit button on index page

查看:112
本文介绍了laravel nova隐藏索引页面上的编辑按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在nova索引页面上禁用编辑/删除按钮并仍然允许详细页面,如果我要创建一个策略,该策略将在所有位置禁用该操作,我想允许在详细页面上进行编辑和删除,但只想从索引中删除这些按钮,

How to disable edit/delete button on nova index page and still allow in detail page, if I will create a policy, that will disable the operation everywhere, I want to allow edit and delete in detail page, but just want to remove those button from index,

做类似

 public function update(User $user, Customer $customer)
    {
        if ( request()->route()->getName('route-name') ) {
            return false;
        }
    }

是正确的方法还是有更好的方法?

is correct way or there is any better way?

推荐答案

如果要禁用索引页上的任何行按钮,请为资源创建一个策略,并在我的情况下在各自的函数上返回false update()

If you want to disable any row button on index page, create a policy for the resource and return false on the respective function in my case update(),

所有其他返回true并在AuthServiceProvider.php上添加策略

all others return true and add the policy on AuthServiceProvider.php add

protected $policies = [
    Post::class => PostPolicy::class,
];

和在资源类中

public static function authorizable()
{
    return true;
}

将禁用该​​按钮.

这篇关于laravel nova隐藏索引页面上的编辑按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆