diff --git a/src/Models/EscaperoomLocation.php b/src/Models/EscaperoomLocation.php index 0dfc3f5..16ea22b 100644 --- a/src/Models/EscaperoomLocation.php +++ b/src/Models/EscaperoomLocation.php @@ -4,7 +4,6 @@ namespace Tipoff\EscapeRoom\Models; -use DrewRoberts\Media\Models\Image; use Tipoff\Locations\Models\Location; use Tipoff\Support\Models\BaseModel; use Tipoff\Support\Traits\HasCreator; @@ -22,7 +21,7 @@ class EscaperoomLocation extends BaseModel */ public function location() { - return $this->belongsTo(Location::class); + return $this->belongsTo(app('location')); } /** @@ -30,6 +29,6 @@ public function location() */ public function teamPhoto() { - return $this->belongsTo(Image::class, 'team_image_id'); + return $this->belongsTo(app('image'), 'team_image_id'); } } diff --git a/src/Models/EscaperoomMarket.php b/src/Models/EscaperoomMarket.php index cd28119..a9573c3 100644 --- a/src/Models/EscaperoomMarket.php +++ b/src/Models/EscaperoomMarket.php @@ -4,7 +4,6 @@ namespace Tipoff\EscapeRoom\Models; -use DrewRoberts\Media\Models\Image; use Tipoff\Locations\Models\Location; use Tipoff\Support\Models\BaseModel; use Tipoff\Support\Traits\HasCreator; @@ -22,7 +21,7 @@ class EscaperoomMarket extends BaseModel */ public function location() { - return $this->belongsTo(Location::class); + return $this->belongsTo(app('location')); } /** @@ -30,6 +29,6 @@ public function location() */ public function teamPhoto() { - return $this->belongsTo(Image::class, 'team_image_id'); + return $this->belongsTo(app('image'), 'team_image_id'); } } diff --git a/src/Models/EscaperoomRate.php b/src/Models/EscaperoomRate.php index b54ceae..b417745 100644 --- a/src/Models/EscaperoomRate.php +++ b/src/Models/EscaperoomRate.php @@ -4,12 +4,13 @@ namespace Tipoff\EscapeRoom\Models; +use Tipoff\Support\Contracts\Booking\BookingRateInterface; use Tipoff\Support\Models\BaseModel; use Tipoff\Support\Traits\HasCreator; use Tipoff\Support\Traits\HasPackageFactory; use Tipoff\Support\Traits\HasUpdater; -class EscaperoomRate extends BaseModel +class EscaperoomRate extends BaseModel /*implements BookingRateInterface*/ { use HasCreator; use HasUpdater; @@ -17,6 +18,8 @@ class EscaperoomRate extends BaseModel protected $casts = []; + public $amount; + protected static function boot() { parent::boot(); @@ -122,12 +125,14 @@ public function getRouteKeyName() * @param bool $isPrivate * @return int */ - public function getAmount(int $participants, bool $isPrivate) + public function generateAmount(int $participants, bool $isPrivate): int { $key = ($isPrivate) ? 'private_' : 'public_'; $key = $key.$participants; - return $this->$key * $participants; + $this->amount = $this->$key * $participants; + + return $this->amount; } /** @@ -161,4 +166,39 @@ public function schedules() { return $this->hasMany(app('schedule')); } + + public function getAmount(): int + { + return $this->amount; + } + + public function getLabel(): string + { + // @todo: implement getLabel + return ""; + } + + public function getSlug(): string + { + // @todo: implement getSlug + return ""; + } + + public function category(): Relation + { + // @todo: implement category + return null; + } + + public function getCategory(): BookingRateCategoryInterface + { + // @todo: implement getCategory + return null; + } + + public function getParticipantsLimit(): ?int + { + // @todo: implement getParticipantsLimit + return 1; + } } diff --git a/src/Models/EscaperoomTheme.php b/src/Models/EscaperoomTheme.php index 41f7e04..2147842 100644 --- a/src/Models/EscaperoomTheme.php +++ b/src/Models/EscaperoomTheme.php @@ -45,17 +45,17 @@ protected static function boot() public function rooms() { - return $this->hasMany(Room::class); + return $this->hasMany(app('room')); } public function locations() { - return $this->hasManyThrough(app('location'), Room::class, 'escaperoom_theme_id', 'id', 'id', 'location_id'); + return $this->hasManyThrough(app('location'), app('room'), 'escaperoom_theme_id', 'id', 'id', 'location_id'); } public function supervision() { - return $this->belongsTo(Supervision::class); + return $this->belongsTo(app('supervision')); } public function images() diff --git a/tests/Unit/Models/EscaperoomRateModelTest.php b/tests/Unit/Models/EscaperoomRateModelTest.php index 0bea679..b78d13c 100644 --- a/tests/Unit/Models/EscaperoomRateModelTest.php +++ b/tests/Unit/Models/EscaperoomRateModelTest.php @@ -107,7 +107,7 @@ public function always_return_amount(EscaperoomRate $model) { $isPrivate = (bool)rand(0, 1); $participants = rand(1, 9); - $amount = $model->getAmount($participants, $isPrivate); + $amount = $model->generateAmount($participants, $isPrivate); $this->assertIsInt($amount); }