斯洛文尼亚蜘蛛怎么翻译_斯洛文尼亚日期选择器,用于Laravel Nova

介绍了一种为Laravel Nova应用提供斯洛文尼亚本地化日期时间选择器的方法,通过使用SlovenianDateTime类,可以轻松地将日期时间字段格式化为斯洛文尼亚语环境,无需大量代码重构。

斯洛文尼亚蜘蛛怎么翻译

斯洛文尼亚日期时间 (Slovenian DateTime)

Apply Slovenian localisation to Laravel Nova's default DateTime field that currently doesn't support localisation out of the box.

将Slovenian本地化应用于Laravel Nova的默认DateTime字段,该字段当前不支持本地化。

斯洛文尼亚日期选择器,用于Laravel Nova (Slovenian datepicker for Laravel Nova)

Apply Slovenian localisation to Laravel Nova's default DateTime field that currently doesn't support localisation out of the box.

将Slovenian本地化应用于Laravel Nova的默认DateTime字段,该字段当前不支持本地化。

安装 (Installation)

You can install the package in to a Laravel app that uses Nova via composer:

您可以通过composer将软件包安装到使用Nova的Laravel应用中:

composer require techouse/slovenian-date-time

用法 (Usage)

The API is exactly the same as with Nova's default DateTime Field

该API与Nova的默认DateTime字段完全相同

Simply use SlovenianDateTime class instead of DateTime directly or alias it like the example below so you won't have to refactor too much existing code.

只需直接使用SlovenianDateTime类而不是DateTime即可,也可以像下面的示例一样使用别名,因此您不必重构太多的现有代码。

<?php

namespace App\Nova;

use Illuminate\Http\Request;
use Laravel\Nova\Fields\{ID, Password, Select, Text};
use Techouse\SlovenianDateTime\SlovenianDateTime as DateTime;

class User extends Resource
{
    /**
     * The model the resource corresponds to.
     *
     * @var string
     */
    public static $model = 'App\User';

    /**
     * The single value that should be used to represent the resource when being displayed.
     *
     * @var string
     */
    public static $title = 'name';

    /**
     * The columns that should be searched.
     *
     * @var array
     */
    public static $search = ['name',
                             'email'];

    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),

            Text::make(__('Name'), 'name')
                ->sortable()
                ->rules('required', 'max:255'),

            Text::make(__('Email Address'), 'email')
                ->sortable()
                ->rules('required', 'email', 'max:254')
                ->creationRules('unique:users,email')
                ->updateRules('unique:users,email,{{resourceId}}'),

            Password::make(__('Password'), 'password')
                    ->onlyOnForms()
                    ->creationRules('required', 'string', 'min:6')
                    ->updateRules('nullable', 'string', 'min:6'),

            DateTime::make(__('Created at'), 'created_at')
                    ->format('DD.MM.YYYY HH:mm:ss')
                    ->creationRules('required', 'date')
                    ->sortable(),

            DateTime::make(__('Updated at'), 'updated_at')
                    ->format('DD.MM.YYYY HH:mm:ss')
                    ->updateRules('required', 'date')
                    ->hideFromIndex(),
        ];
    }

    /**
     * Get the cards available for the request.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function cards(Request $request)
    {
        return [];
    }

    /**
     * Get the filters available for the resource.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function filters(Request $request)
    {
        return [];
    }

    /**
     * Get the lenses available for the resource.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function lenses(Request $request)
    {
        return [];
    }

    /**
     * Get the actions available for the resource.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function actions(Request $request)
    {
        return [];
    }
}

翻译自: https://vuejsexamples.com/slovenian-datepicker-for-laravel-nova/

斯洛文尼亚蜘蛛怎么翻译

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值