62 lines
1.5 KiB
PHP
62 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Penilaian extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'penilaian';
|
|
protected $primaryKey = 'PenilaianId';
|
|
|
|
protected $guarded = [];
|
|
|
|
// protected $fillable = [
|
|
// 'ms_sekolah_id',
|
|
// 'npsn',
|
|
// // 'ms_form_kriteria_id',
|
|
// 'key',
|
|
// 'page_number',
|
|
// 'value',
|
|
// 'skor',
|
|
// 'status',
|
|
// 'tahun',
|
|
// 'created_by',
|
|
// 'level_adiwiyata',
|
|
// ];
|
|
|
|
protected static function booted()
|
|
{
|
|
static::addGlobalScope('filterSekolah', function (Builder $builder) {
|
|
|
|
$role = session('group_alias'); // misal: dinas_pendidikan atau kemenag
|
|
|
|
if (($role == 'dinas_pendidikan') || ($role == 'penilai_disdik')) {
|
|
|
|
$builder->whereHas('sekolah', function ($q) {
|
|
$q->where('is_kemenag', false);
|
|
});
|
|
|
|
} elseif (($role == 'kemenag') || ($role == 'penilai_kemenag')) {
|
|
|
|
$builder->whereHas('sekolah', function ($q) {
|
|
$q->where('is_kemenag', true);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
public function page()
|
|
{
|
|
return $this->belongsTo(\App\Models\Master\FormKriteria::class,'page_number','page_number');
|
|
}
|
|
|
|
public function sekolah()
|
|
{
|
|
return $this->belongsTo(\App\Models\Master\Sekolah::class,'ms_sekolah_id','MsSekolahId');
|
|
}
|
|
}
|