<?php

namespace App\Models;

use App\Traits\HasImages;
use App\Traits\HasSortsTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class AppHowToUseStep extends Model
{
    use HasFactory, HasImages, HasSortsTrait;

    public const IMAGE_UPLOAD_TO = 'uploads/app-how-to-use-steps';
    public const IMAGE_SIZE_SMALL = 'small';
    public const IMAGE_SIZE_LARGE = 'large';

    protected $table = 'app_how_to_use_steps';

    protected $fillable = [
        'title',
        'description',
        'is_active',
        'order_no',
    ];

    protected $casts = [
        'is_active' => 'bool',
        'order_no' => 'integer',
        'created_at' => 'datetime:d-m-Y H:i:s',
        'updated_at' => 'datetime:d-m-Y H:i:s',
    ];

    protected $appends = [
        'image',
    ];

    protected $allowedSorts = [
        'id',
        'title',
        'description',
        'is_active',
        'order_no',
        'created_at',
    ];

    public function getImageAttribute(): ?string
    {
        return $this->getThumbnail(null, self::IMAGE_SIZE_LARGE);
    }
}
