<?php

namespace App\Models\SettingManagement;

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

class Setting extends Model{
    use HasFactory;

    protected $table = "setting_mgt__settings";
    //public $timestamps = false;
    protected $guarded = [];


    protected static  function booted(){

        parent::creating(function (Setting $setting){
              $attributes = $setting->getAttributes();
              if (blank($attributes['display_name'])){
                  $setting->setAttribute("display_name",$attributes['key']);
              }
        });
    }


    public function getDisplayNameAttribute($value){
        return ucfirst(str_replace("_"," ",$this->key));
    }

}
