ホームページ  >  記事  >  バックエンド開発  >  Filament Traitを使用して(作成、更新)後にリストページにリダイレクトする方法

Filament Traitを使用して(作成、更新)後にリストページにリダイレクトする方法

王林
王林オリジナル
2024-08-22 20:31:07550ブラウズ

Filament How to redirect to list page after (create,update) using Trait

Filament v3 でリソースを作成または更新した後にリスト ページにリダイレクトするには、リソース クラスでカスタム特性を使用できます。

カスタム特性を作成する

<?php

namespace App\Traits;

trait RedirectIndex
{
    protected function getRedirectUrl(): string
    {
        return $this->getResource()::getUrl('index');
    }
}

フィラメント リソースで特性を使用する

class CreateProduct extends CreateRecord
{
    protected static string $resource = ProductResource::class;

   //add trait in your CreateRecord or UpdateRecord
    use \App\Traits\RedirectIndex; 
}

以上がFilament Traitを使用して(作成、更新)後にリストページにリダイレクトする方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。