first commit
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\DokSiremun;
|
||||
|
||||
use App\Models\Verifikator\Akreditasi;
|
||||
use App\Models\Verifikator\Prodi;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Mengajar extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'public.mengajars';
|
||||
protected $fillable = [
|
||||
'absen',
|
||||
'jumlah_pertemuan',
|
||||
'total_pertemuan',
|
||||
'status_verifikasi_id',
|
||||
];
|
||||
|
||||
function statusVerifikasi()
|
||||
{
|
||||
return $this->belongsTo(StatusVerifikasi::class, 'status_verifikasi_id', 'id');
|
||||
}
|
||||
|
||||
function logs()
|
||||
{
|
||||
return $this->morphMany(LogPengajuan::class, 'logable');
|
||||
}
|
||||
|
||||
function notes()
|
||||
{
|
||||
return $this->morphMany(CatatanPengajuan::class, 'noteable');
|
||||
}
|
||||
|
||||
function syarats()
|
||||
{
|
||||
return $this->hasOne(self::class, 'id', 'id');
|
||||
}
|
||||
|
||||
function unit()
|
||||
{
|
||||
return $this->belongsTo(UnitKerja::class, 'id_unit_kerja', 'id');
|
||||
}
|
||||
|
||||
function prodi()
|
||||
{
|
||||
return $this->belongsTo(Prodi::class, 'id_sub_unit_kerja', 'id');
|
||||
}
|
||||
|
||||
function pengali()
|
||||
{
|
||||
return $this->hasOneThrough(
|
||||
Akreditasi::class, // Model tujuan akhir (Akreditasi)
|
||||
Prodi::class, // Model perantara (Prodi)
|
||||
'id', // Foreign key di tabel Prodi (default: id_prodi dari Mengajar)
|
||||
'id', // Foreign key di tabel Akreditasi (default: id dari Prodi)
|
||||
'id_sub_unit_kerja', // Local key di tabel Mengajar
|
||||
'akreditasi_id' // Local key di tabel Prodi yang menghubungkan ke Akreditasi
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user