armincms / nova-opening-hours
spatie 开放时间的 Nova 包装字段。
0.3.0
2020-12-06 10:55 UTC
Requires
- php: >=7.1.0
README
spatie 开放时间的 Nova 字段。
安装
composer require armincms/nova-opening-hours
用法
首先,在 Laravel 模型中应将属性转换为数组,然后在 Nova 资源中遵循以下步骤
use Armincms\Fields\OpeningHours;
...
OpeningHours::make('Name')
...
限制
您可以使用 restrictTo
限制用户输入特定时间,如下所示
OpeningHours::make(__('Opening Hours'), '_sfore_opening_hours_')
->restrictTo([
'first restriction' => 'Label',
'second restriction' => 'Label',
...
])
此限制将应用于所有工作日。如果您想限制某些日子,请使用以下方法
OpeningHours::make(__('Opening Hours'), '_sfore_opening_hours_')
->restrictionOnSunday([
'first restriction' => 'Label',
'second restriction' => 'Label',
...
])
->restrictionOnWednesday([
'first restriction' => 'Label',
'second restriction' => 'Label',
...
])
存储
此软件包以以下格式存储开放时间
$openingHours = [
'sunday' => [
[
'data' => 'your data',
'hours' => 'your hours', // 00:08-10:00
],
[
'data' => 'your second data',
'hours' => 'your second hours', // 11:00-20:00
]
],
'friday' => [
[
'data' => 'your data',
'hours' => 'your hours', // 00:08-10:00
],
[
'data' => 'your second data',
'hours' => 'your second hours', // 11:00-20:00
]
],
];