Files
fewo-stommer/app/Models/Extra.php
T
LarsandCursor 8ebc1a3878 Assign the existing site to one landlord so stommer.info can run tenancy.
Seebad 0.3 stays in this release. With a single landlord every host still reaches the default website.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-23 12:00:11 +02:00

55 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use App\Enums\ExtraPricing;
use App\Models\Concerns\BelongsToTenant;
use Database\Factories\ExtraFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* An optional bookable service such as bed linen or towels.
*/
#[Fillable(['property_id', 'name', 'description', 'price', 'pricing', 'is_active', 'sort_order'])]
class Extra extends Model
{
/** @use HasFactory<ExtraFactory> */
use BelongsToTenant, HasFactory;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'pricing' => ExtraPricing::class,
'is_active' => 'boolean',
];
}
/**
* @return BelongsTo<Property, $this>
*/
public function property(): BelongsTo
{
return $this->belongsTo(Property::class);
}
/**
* @param Builder<Extra> $query
* @return Builder<Extra>
*/
#[Scope]
protected function active(Builder $query): Builder
{
return $query->where('is_active', true);
}
}