first commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user