Files
verifikator/app/Models/Verifikator/JabatanPegawai.php
T
2026-08-07 10:47:09 +07:00

54 lines
1.3 KiB
PHP

<?php
namespace App\Models\Verifikator;
use App\Models\DokSiremun\CatatanPengajuan;
use App\Models\DokSiremun\LogPengajuan;
use App\Models\Verifikator\View\Pegawai;
use Illuminate\Database\Eloquent\Model;
class JabatanPegawai extends Model
{
protected $table = 'verifikator.jabatan_pegawais';
protected $guarded = [];
function getSkJabatanFungsionalAttribute($value): string | null
{
if (!$value) return null;
if (str_starts_with($value, 'http')) return $value;
return "https://" . request()->getHost() . "/storage/jabatan/fungsional/$value";
}
function getSkJabatanTambahanAttribute($value): string | null
{
if (!$value) return null;
if (str_starts_with($value, 'http')) return $value;
return "https://" . request()->getHost() . "/storage/jabatan/tambahan/$value";
}
function pegawai()
{
return $this->belongsTo(Pegawai::class, 'nip', 'nip');
}
function detail()
{
return $this->hasMany(JabatanPegawaiDetail::class);
}
function logs()
{
return $this->morphMany(LogPengajuan::class, 'logable');
}
function notes()
{
return $this->morphMany(CatatanPengajuan::class, 'noteable');
}
function scopeActive($query)
{
return $query->where('active', true);
}
}