Skip to content

Commit

Permalink
add inverse relationships for timezone model
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Oct 4, 2021
1 parent 72374ff commit c527779
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Country::where('name', 'like', 'a%')->get(); // Get information about all countr
|--|--|
| `countries` | [`Squire\Models\Country`](#squiremodelscountry) |
| `regions` | [`Squire\Models\Region`](#squiremodelsregion) |
| `timezones` | [`Squire\Models\Timezone`](#squiremodelstimezone) |

### `Squire\Models\Country`

Expand Down Expand Up @@ -173,6 +174,7 @@ Country::where('name', 'like', 'a%')->get(); // Get information about all countr
| `continent` | [`Squire\Models\Continent`](#squiremodelscontinent) |
| `currency` | [`Squire\Models\Currency`](#squiremodelscurrency) |
| `regions` | [`Squire\Models\Region`](#squiremodelsregion) |
| `timezones` | [`Squire\Models\Timezone`](#squiremodelstimezone) |

### `Squire\Models\Currency`

Expand Down
5 changes: 5 additions & 0 deletions packages/continents/src/Models/Continent.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ public function regions(): HasManyThrough
{
return $this->hasManyThrough(Region::class, Country::class);
}

public function timezones(): HasManyThrough
{
return $this->hasManyThrough(Timezone::class, Country::class);
}
}
5 changes: 5 additions & 0 deletions packages/countries/src/Models/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ public function regions(): HasMany
{
return $this->hasMany(Region::class);
}

public function timezones(): HasMany
{
return $this->hasMany(Timezone::class);
}
}

0 comments on commit c527779

Please sign in to comment.