0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Filament 2.x】Resourceクラスで作成機能だけ無効化する

Posted at

概要

以下のようにリソースクラスを作成すると

$ php artisan make:filament-resource Customer -- generate
  • 一覧
  • 新規登録
  • 編集

機能が自動生成される

作成機能や編集機能を無効化させたい際、ドキュメントにはポリシー使えと書いてあるが面倒臭い
誰であろうと無効化したい。

Resourceクラス内でcanCreateをオーバーライド

class CustomerResource extends Resource
{
    public static function canCreate(): bool
    {
        return false;
    }

これで一覧ページの右上の作成ボタンが消え、URL直打ちしても404になる

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?