如何更改Laravel-Nova动作名称?

问题描述 投票:0回答:1

实际上,我需要更改laravel nova动作名称,例如将其翻译成不同的语言。

class PrintWithDetail extends Action
{
    use InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Perform the action on the given models.
     *
     * @param  \Laravel\Nova\Fields\ActionFields  $fields
     * @param  \Illuminate\Support\Collection  $models
     * @return mixed
     */
    public function handle(ActionFields $fields, Collection $models)
    {
        $id = '';
        //
        foreach ($models as $model) {
            $id = $model->id;
        }
        return Action::openInNewTab(route("print.work.order", [$id, 'type' => 'detail']));
    }

}

以上动作显示PrintWithDetail作为名称。

但是,我需要将PrintWithDetail更改为荷兰语。

laravel laravel-nova
1个回答
0
投票

覆盖公共财产$name

/**
 * The displayable name of the action.
 *
 * @var string
 */
public $name;

因此在您的示例中

class PrintWithDetail extends Action
{
    use InteractsWithQueue, Queueable, SerializesModels;

    public $name = "Print met detail";

    /**
     * Perform the action on the given models.
     *
     * @param  \Laravel\Nova\Fields\ActionFields  $fields
     * @param  \Illuminate\Support\Collection  $models
     * @return mixed
     */
    public function handle(ActionFields $fields, Collection $models)
    {
        $id = '';
        //
        foreach ($models as $model) {
            $id = $model->id;
        }
        return Action::openInNewTab(route("print.work.order", [$id, 'type' => 'detail']));
    }
}

您可以在nova/src/Actions/Action.php中扩展操作扩展的类中看到的所有可以更改的内容>

希望这会有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.