Laravel Community Tools by Tighten
Laravel Nova icon Nova Packages
T

The opening hours field for the spatie opening hours package

Readme

nova-opening-hours

A Nova field for the Spatie opening hours.

Installation

composer require armincms/nova-opening-hours

Usage

At the first, In the Laravel model should cast the attribute to the Array then In the Nova resources follow the below:

use Armincms\Fields\OpeningHours;

...
OpeningHours::make('Name')
...

Restriction

You can use the restrictTo to restrict the user to enter specific hours, like the below:

OpeningHours::make(__('Opening Hours'), '_sfore_opening_hours_')
            ->restrictTo([ 
              'first restriction' => 'Label',
              'second restriction' => 'Label', 
              ...
            ]) 

This restriction will apply to all weekdays. if you want to restrict some days use the following:

OpeningHours::make(__('Opening Hours'), '_sfore_opening_hours_')
            ->restrictionOnSunday([ 
              'first restriction' => 'Label',
              'second restriction' => 'Label', 
              ...
            ]) 
            ->restrictionOnWednesday([ 
              'first restriction' => 'Label',
              'second restriction' => 'Label', 
              ...
            ]) 

Storing

This package stores the opening hours in the following format:

$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
      ]
    ],
];

Back to Top
Added 5 years ago
Last updated 5 Years Ago
Version 0.3.0
Composer
armincms/nova-opening-hours
GitHub stars 4
Packagist downloads 876

Favorites

5 users favorited

Rating

5.00
(out of 5)
★★★★★
★★★★
★★★
★★
1 ratings

Contributors

Brought to you by Tighten

Issues/Feature Requests Stats Package Ideas