<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Tag extends Model
{
    protected $table = "tags";
    public $timestamps = false;
    protected $fillable = [
        "tag_code", "owner_id", "status", "item_type", "description",
        "photo_url", "phone", "address", "notes", "sms_enabled",
        "product_id", "order_id",
    ];
    protected $casts = ["sms_enabled" => "boolean"];

    public function owner(): BelongsTo { return $this->belongsTo(User::class, "owner_id"); }
    public function product(): BelongsTo { return $this->belongsTo(Product::class); }
    public function order(): BelongsTo { return $this->belongsTo(Order::class); }
    public function scans(): HasMany { return $this->hasMany(Scan::class, "tag_id"); }
}
