update
parent
89167a425e
commit
28b0eb6b0f
|
|
@ -13,6 +13,28 @@ class Kuesioner extends Model
|
|||
protected $primaryKey = 'KuesionerId';
|
||||
protected $guarded = [];
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::addGlobalScope('filterSekolah', function (Builder $builder) {
|
||||
|
||||
$role = session('group_alias'); // misal: dinas_pendidikan atau kemenag
|
||||
|
||||
if ($role == 'dinas_pendidikan') {
|
||||
|
||||
$builder->whereHas('sekolah', function ($q) {
|
||||
$q->where('is_kemenag', false);
|
||||
});
|
||||
|
||||
} elseif ($role == 'kemenag') {
|
||||
|
||||
$builder->whereHas('sekolah', function ($q) {
|
||||
$q->where('is_kemenag', true);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public function sekolah()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Master\Sekolah::class,'ms_sekolah_id');
|
||||
|
|
|
|||
Loading…
Reference in New Issue