Files
ladill-pos/app/Models/PosLocation.php
T
isaaccladandCursor 9d7dac6c24
Deploy Ladill POS / deploy (push) Successful in 1m58s
Add multi-branch POS with team roles and branch-scoped cashiers.
Pro and Business users can manage branches, invite cashiers with branch assignment, and switch registers; sales and register flows respect acting location.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 06:05:30 +00:00

72 lines
1.6 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\Storage;
class PosLocation extends Model
{
public const STYLE_RETAIL = 'retail';
public const STYLE_RESTAURANT = 'restaurant';
protected $fillable = [
'owner_ref',
'name',
'currency',
'is_default',
'service_style',
'receipt_footer',
'receipt_header',
'receipt_logo_path',
'printer_paper_mm',
'printer_auto_print',
];
protected function casts(): array
{
return [
'is_default' => 'boolean',
'printer_paper_mm' => 'integer',
'printer_auto_print' => 'boolean',
];
}
public function isRestaurant(): bool
{
return $this->service_style === self::STYLE_RESTAURANT;
}
public function receiptLogoUrl(): ?string
{
if (! $this->receipt_logo_path) {
return null;
}
return Storage::disk('public')->url($this->receipt_logo_path);
}
public function products(): HasMany
{
return $this->hasMany(PosProduct::class, 'location_id');
}
public function tables(): HasMany
{
return $this->hasMany(PosTable::class, 'location_id');
}
public function sales(): HasMany
{
return $this->hasMany(PosSale::class, 'location_id');
}
public function scopeOwned(Builder $query, string $ownerRef): Builder
{
return $query->where('owner_ref', $ownerRef);
}
}