52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models\DokSiremun;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Kegiatan extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $table = 'public.kegiatans';
|
|
protected $guarded = [];
|
|
|
|
function syarats()
|
|
{
|
|
return $this->hasMany(Syarat::class, 'id_kegiatan', 'id');
|
|
}
|
|
|
|
function logs()
|
|
{
|
|
return $this->morphMany(LogPengajuan::class, 'logable');
|
|
}
|
|
|
|
function unit()
|
|
{
|
|
return $this->belongsTo(UnitKerja::class, 'id_unit_kerja');
|
|
}
|
|
|
|
function unitPembayaran()
|
|
{
|
|
return $this->belongsTo(UnitKerja::class, 'id_unit_kerja_pimpinan');
|
|
}
|
|
|
|
function getNamaSkAttribute($value): string | null
|
|
{
|
|
if (!$value) {
|
|
return null;
|
|
}
|
|
|
|
if (str_starts_with($value, 'http')) {
|
|
return $value;
|
|
}
|
|
|
|
$unit = UnitKerja::find($this->id_unit_kerja);
|
|
$sk = "https://siska.untan.ac.id/storage/sk/$unit->nama/$value";
|
|
|
|
return $sk;
|
|
}
|
|
}
|