first commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Verifikator;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RubrikDetail extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'verifikator.rubrik_details';
|
||||
protected $fillable = [
|
||||
'rubrik_id',
|
||||
'pelaksana_id', // 1 = Tendik, 3 = Dosen
|
||||
'nilai'
|
||||
];
|
||||
|
||||
protected $appends = ['is_show'];
|
||||
|
||||
public function rubrik()
|
||||
{
|
||||
return $this->belongsTo(Rubrik::class, 'rubrik_id');
|
||||
}
|
||||
|
||||
// Virtual relation untuk pelaksana
|
||||
public function getPelaksanaAttribute()
|
||||
{
|
||||
return (object)[
|
||||
'nama' => $this->pelaksana_id == 1 ? 'tendik' : ($this->pelaksana_id == 3 ? 'dosen' : 'unknown')
|
||||
];
|
||||
}
|
||||
|
||||
// is_show selalu 1 untuk saat ini
|
||||
public function getIsShowAttribute()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Helper methods to get employee type
|
||||
public function getJenisPegawaiAttribute()
|
||||
{
|
||||
return $this->pelaksana_id == 1 ? 'tendik' : ($this->pelaksana_id == 3 ? 'dosen' : 'unknown');
|
||||
}
|
||||
|
||||
public function getJenisPegawaiNamaAttribute()
|
||||
{
|
||||
return $this->pelaksana_id == 1 ? 'Tendik' : ($this->pelaksana_id == 3 ? 'Dosen' : 'Unknown');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user