<?php
 namespace App\Models; use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Crypt; class RegistrarSetting extends Model { use HasFactory; protected $fillable = [ 'registrar_id', 'setting', 'value', ]; public function getValueAttribute(?string $value): ?string { if ($value === null || $value === '') { return $value; } try { return Crypt::decryptString($value); } catch (DecryptException $e) { return $value; } } public function setValueAttribute(?string $value): void { if ($value === null || $value === '') { $this->attributes['value'] = $value; return; } $this->attributes['value'] = Crypt::encryptString($value); } public function registrar() { return $this->belongsTo(Registrar::class); } } 