<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class BeforeAfter extends Model
{
    use HasFactory;

    protected $table = 'before_afters';
    
    protected $fillable = [
        'before_image',
        'after_image',
        'status',
        'order',
    ];

    public function getBeforeImagePathAttribute()
    {
        return $this->before_image ? asset('storage/before_afters/' . $this->before_image) : asset('assets/dashboard/images/noimage.png');
    }

    public function getAfterImagePathAttribute()
    {
        return $this->after_image ? asset('storage/before_afters/' . $this->after_image) : asset('assets/dashboard/images/noimage.png');
    }

    public function scopeActive($query)
    {
        return $query->where('status', 1);
    }
}

