diff --git a/README.md b/README.md index 9bebec9..eff4092 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,9 @@ You can install the package via composer: composer require datomatic/db-opening-hours ``` -You can publish and run the migrations with: +You can run the migrations with: ```bash -php artisan vendor:publish --tag="db-opening-hours-migrations" php artisan migrate ``` @@ -36,6 +35,12 @@ You can publish the config file with: php artisan vendor:publish --tag="db-opening-hours-config" ``` +You can publish the translations files with: + +```bash +php artisan vendor:publish --tag="db-opening-hours-translations" +``` + This is the contents of the published config file: ```php diff --git a/resources/lang/en/days.php b/resources/lang/en/days.php new file mode 100644 index 0000000..78fe29a --- /dev/null +++ b/resources/lang/en/days.php @@ -0,0 +1,13 @@ + 'Monday', + 'tuesday' => 'Tuesday', + 'wednesday' => 'Wednesday', + 'thursday' => 'Thursday', + 'friday' => 'Friday', + 'saturday' => 'Saturday', + 'sunday' => 'Sunday', +]; diff --git a/resources/lang/it/days.php b/resources/lang/it/days.php new file mode 100644 index 0000000..9635dcf --- /dev/null +++ b/resources/lang/it/days.php @@ -0,0 +1,13 @@ + 'Lunedì', + 'tuesday' => 'Martedì', + 'wednesday' => 'Mercoledì', + 'thursday' => 'Giovedì', + 'friday' => 'Venerdì', + 'saturday' => 'Sabato', + 'sunday' => 'Domenica', +]; diff --git a/resources/lang/nl/days.php b/resources/lang/nl/days.php new file mode 100644 index 0000000..ad51f30 --- /dev/null +++ b/resources/lang/nl/days.php @@ -0,0 +1,13 @@ + 'Maandag', + 'tuesday' => 'Dinsdag', + 'wednesday' => 'Woensdag', + 'thursday' => 'Donderdag', + 'friday' => 'Vrijdag', + 'saturday' => 'Zaterdag', + 'sunday' => 'Zondag', +]; diff --git a/src/Commands/DatabaseOpeningHoursCommand.php b/src/Commands/DatabaseOpeningHoursCommand.php deleted file mode 100644 index f6d211f..0000000 --- a/src/Commands/DatabaseOpeningHoursCommand.php +++ /dev/null @@ -1,19 +0,0 @@ -comment('All done'); - - return self::SUCCESS; - } -} diff --git a/src/DatabaseOpeningHoursServiceProvider.php b/src/DatabaseOpeningHoursServiceProvider.php index b6242df..0fa1f1e 100644 --- a/src/DatabaseOpeningHoursServiceProvider.php +++ b/src/DatabaseOpeningHoursServiceProvider.php @@ -17,6 +17,7 @@ public function configurePackage(Package $package): void $package ->name('db-opening-hours') ->hasConfigFile() + ->hasTranslations() ->hasMigrations([ '100000_create_opening_hours_table', '100001_create_opening_hours_days_table', diff --git a/src/Enums/Day.php b/src/Enums/Day.php index 7dc5032..56ad9c0 100644 --- a/src/Enums/Day.php +++ b/src/Enums/Day.php @@ -14,4 +14,13 @@ enum Day: string case SATURDAY = 'saturday'; case SUNDAY = 'sunday'; + public function getLabel(): ?string + { + return $this->label(); + } + + public function label(): string + { + return __('db-opening-hours::days.'.$this->value); + } } diff --git a/src/Models/OpeningHour.php b/src/Models/OpeningHour.php index 9941e69..7ad7070 100644 --- a/src/Models/OpeningHour.php +++ b/src/Models/OpeningHour.php @@ -35,37 +35,37 @@ public function days(): HasMany public function monday(): HasOne { - return $this->day(Enums\Day::Monday); + return $this->day(Enums\Day::MONDAY); } public function tuesday(): HasOne { - return $this->day(Enums\Day::Tuesday); + return $this->day(Enums\Day::TUESDAY); } public function wednesday(): HasOne { - return $this->day(Enums\Day::Wednesday); + return $this->day(Enums\Day::WEDNESDAY); } public function thursday(): HasOne { - return $this->day(Enums\Day::Thursday); + return $this->day(Enums\Day::THURSDAY); } public function friday(): HasOne { - return $this->day(Enums\Day::Friday); + return $this->day(Enums\Day::FRIDAY); } public function saturday(): HasOne { - return $this->day(Enums\Day::Saturday); + return $this->day(Enums\Day::SATURDAY); } public function sunday(): HasOne { - return $this->day(Enums\Day::Sunday); + return $this->day(Enums\Day::SUNDAY); } private function day(Enums\Day $day): HasOne