<?php

namespace App\Models;

use App\Traits\Auditable;
use App\Traits\DeleteGuarded;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class BusinessLocation extends Model
{
    use HasFactory, SoftDeletes, Auditable, DeleteGuarded;

    protected $fillable = ['name', 'country_id', 'state_id', 'timezone_id', 'city', 'street', 'phone_number', 'email', 'note'];

    public const DELETE_PREVENTING_RELATIONSHIPS = [];
    public const DELETE_AFFECTED_RELATIONSHIPS = [];
    public const NON_STANDALONE_CHILDREN = [];

    /**
     * Get the user who created the business location
     * @return BelongsTo
     */
    public function creator(): BelongsTo
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    /**
     * Get the audit descriptions for different actions.
     *
     * @return array An array containing descriptions for different audit actions
     */
    protected function getAuditDescriptions(): array
    {
        return [
            'create' => "Created new business location : $this->name",
            'update' => "Updated business location : $this->name",
            'delete' => "Deleted business location $this->name",
        ];
    }
}
