<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Storage;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Activitylog\LogOptions;

class Brand extends Model
{
    use HasFactory, SoftDeletes;
    use LogsActivity;

    public function getActivitylogOptions(): LogOptions
    {
        return LogOptions::defaults();
   }

    protected $table = 'brands';
    protected $primaryKey = 'id';

    protected $fillable = [
        'name',
        'code',
        'image',
        'hide_point',
        'priority'
    ];

    public function items()
    {
        return $this->hasMany(Items::class, 'brand_id', 'id');
    }

    public function getImageUrlAttribute()
    {
        return $this->image ? Storage::disk('wms')->url($this->image) : null;
    }


    public function getImageDarkUrlAttribute()
    {
        return $this->image ? Storage::disk('wms')->url($this->image) : null;
    }
}
