<?php

namespace App\Models;

use App\Models\Concerns\HasModuleMedia;
use App\Models\Concerns\InteractsWithActivityLog;
use Illuminate\Database\Eloquent\Attributes\Guarded;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia;

#[Guarded(['id'])]
class HomepageConfiguration extends Model implements HasMedia
{
    // 1. Use Trait
    use HasFactory, HasModuleMedia, InteractsWithActivityLog;

    // 2. Other Methods
    public static function instance(): self
    {
        return static::query()->firstOrCreate(['id' => 1]);
    }

    public static function mediaModuleName(): string
    {
        return 'homepage';
    }

    public function registerMediaCollections(): void
    {
        $this->addMediaCollection('about_image')->singleFile();
        $this->addMediaCollection('gallery');
        $this->addMediaCollection('hero_image')->singleFile();
    }
}
