Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
trippo committed Aug 23, 2024
1 parent 24fdcb2 commit 2783c10
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 28 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions resources/lang/en/days.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

return [
'monday' => 'Monday',
'tuesday' => 'Tuesday',
'wednesday' => 'Wednesday',
'thursday' => 'Thursday',
'friday' => 'Friday',
'saturday' => 'Saturday',
'sunday' => 'Sunday',
];
13 changes: 13 additions & 0 deletions resources/lang/it/days.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

return [
'monday' => 'Lunedì',
'tuesday' => 'Martedì',
'wednesday' => 'Mercoledì',
'thursday' => 'Giovedì',
'friday' => 'Venerdì',
'saturday' => 'Sabato',
'sunday' => 'Domenica',
];
13 changes: 13 additions & 0 deletions resources/lang/nl/days.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

return [
'monday' => 'Maandag',
'tuesday' => 'Dinsdag',
'wednesday' => 'Woensdag',
'thursday' => 'Donderdag',
'friday' => 'Vrijdag',
'saturday' => 'Zaterdag',
'sunday' => 'Zondag',
];
19 changes: 0 additions & 19 deletions src/Commands/DatabaseOpeningHoursCommand.php

This file was deleted.

1 change: 1 addition & 0 deletions src/DatabaseOpeningHoursServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 9 additions & 0 deletions src/Enums/Day.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
14 changes: 7 additions & 7 deletions src/Models/OpeningHour.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2783c10

Please sign in to comment.