<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Store extends Model
{
    use HasUlids, SoftDeletes;

    protected $fillable = [
        'user_id', 'local_id', 'name', 'type', 'country_code', 'currency_code',
        'currency_symbol', 'address', 'phone', 'whatsapp_number', 'tax_number',
        'logo_path', 'tax_percent', 'service_fee_percent', 'is_active',
        'device_id', 'sync_version', 'is_deleted',
    ];

    protected $casts = [
        'tax_percent' => 'float',
        'service_fee_percent' => 'float',
        'is_active' => 'boolean',
        'is_deleted' => 'boolean',
        'sync_version' => 'integer',
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

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

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