short_code) { do { $code = strtolower(Str::random(8)); } while (static::where('short_code', $code)->exists()); $this->forceFill(['short_code' => $code])->save(); } return $this->short_code; } protected function casts(): array { return [ 'seats' => 'integer', 'current_sale_id' => 'integer', 'position' => 'integer', ]; } public function location(): BelongsTo { return $this->belongsTo(PosLocation::class, 'location_id'); } public function currentSale(): BelongsTo { return $this->belongsTo(PosSale::class, 'current_sale_id'); } public function isFree(): bool { return $this->status === self::STATUS_FREE; } public function scopeOwned(Builder $query, string $ownerRef): Builder { return $query->where('owner_ref', $ownerRef); } }