role permission belom

This commit is contained in:
annajwasz 2025-04-25 21:17:10 +07:00
parent ee4b4c2404
commit 9214aa0a31
10 changed files with 667 additions and 72 deletions

View File

@ -1,88 +1,88 @@
<?php
namespace App\Models;
// namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
// use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Illuminate\Database\Eloquent\Model;
// use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Listform extends Model
{
use HasFactory;
// class Listform extends Model
// {
// use HasFactory;
protected $guarded = [];
// protected $guarded = [];
protected $casts = [
'nilai_kepemilikan_kip' => 'decimal:7',
'nilai_tingkatan_desil' => 'decimal:7',
'nilai_kondisi_ekonomi' => 'decimal:7',
'total_nilai' => 'decimal:7',
];
// protected $casts = [
// 'nilai_kepemilikan_kip' => 'decimal:7',
// 'nilai_tingkatan_desil' => 'decimal:7',
// 'nilai_kondisi_ekonomi' => 'decimal:7',
// 'total_nilai' => 'decimal:7',
// ];
public function mahasiswa(): BelongsTo
{
return $this->belongsTo(Mahasiswa::class);
}
// public function mahasiswa(): BelongsTo
// {
// return $this->belongsTo(Mahasiswa::class);
// }
protected static function boot()
{
parent::boot();
// protected static function boot()
// {
// parent::boot();
static::saving(function ($listform) {
// Hitung jumlah berkas yang diupload
$berkasCount = 0;
if (!empty($listform->berkas_sktm)) $berkasCount++;
if (!empty($listform->berkas_ppke)) $berkasCount++;
if (!empty($listform->berkas_pmk)) $berkasCount++;
if (!empty($listform->berkas_pkh)) $berkasCount++;
if (!empty($listform->berkas_kks)) $berkasCount++;
// static::saving(function ($listform) {
// // Hitung jumlah berkas yang diupload
// $berkasCount = 0;
// if (!empty($listform->berkas_sktm)) $berkasCount++;
// if (!empty($listform->berkas_ppke)) $berkasCount++;
// if (!empty($listform->berkas_pmk)) $berkasCount++;
// if (!empty($listform->berkas_pkh)) $berkasCount++;
// if (!empty($listform->berkas_kks)) $berkasCount++;
// Tentukan kondisi ekonomi dan nilai berdasarkan jumlah berkas
if ($berkasCount >= 4) {
$listform->kondisi_ekonomi = 'Sangat Kurang Mampu';
$listform->nilai_kondisi_ekonomi = 0.4;
} elseif ($berkasCount >= 2) {
$listform->kondisi_ekonomi = 'Kurang Mampu';
$listform->nilai_kondisi_ekonomi = 0.3;
} else {
$listform->kondisi_ekonomi = 'Cukup Mampu';
$listform->nilai_kondisi_ekonomi = 0.3;
}
// // Tentukan kondisi ekonomi dan nilai berdasarkan jumlah berkas
// if ($berkasCount >= 4) {
// $listform->kondisi_ekonomi = 'Sangat Kurang Mampu';
// $listform->nilai_kondisi_ekonomi = 0.4;
// } elseif ($berkasCount >= 2) {
// $listform->kondisi_ekonomi = 'Kurang Mampu';
// $listform->nilai_kondisi_ekonomi = 0.3;
// } else {
// $listform->kondisi_ekonomi = 'Cukup Mampu';
// $listform->nilai_kondisi_ekonomi = 0.3;
// }
// Hitung total nilai
$totalNilai = 0;
// // Hitung total nilai
// $totalNilai = 0;
// Nilai dari Kepemilikan KIP
if ($listform->kepemilikan_kip === 'Memiliki KIP') {
$totalNilai += 0.6;
} else {
$totalNilai += 0.4;
}
// // Nilai dari Kepemilikan KIP
// if ($listform->kepemilikan_kip === 'Memiliki KIP') {
// $totalNilai += 0.6;
// } else {
// $totalNilai += 0.4;
// }
// Nilai dari Tingkatan Desil
switch ($listform->tingkatan_desil) {
case 'Desil 1':
$totalNilai += 0.35;
break;
case 'Desil 2':
$totalNilai += 0.25;
break;
case 'Desil 3':
$totalNilai += 0.20;
break;
case 'Desil 4':
$totalNilai += 0.15;
break;
case 'Desil 5':
$totalNilai += 0.05;
break;
}
// // Nilai dari Tingkatan Desil
// switch ($listform->tingkatan_desil) {
// case 'Desil 1':
// $totalNilai += 0.35;
// break;
// case 'Desil 2':
// $totalNilai += 0.25;
// break;
// case 'Desil 3':
// $totalNilai += 0.20;
// break;
// case 'Desil 4':
// $totalNilai += 0.15;
// break;
// case 'Desil 5':
// $totalNilai += 0.05;
// break;
// }
// Tambahkan nilai kondisi ekonomi
$totalNilai += $listform->nilai_kondisi_ekonomi;
// // Tambahkan nilai kondisi ekonomi
// $totalNilai += $listform->nilai_kondisi_ekonomi;
$listform->total_nilai = $totalNilai;
});
}
// $listform->total_nilai = $totalNilai;
// });
// }
}
// }

View File

@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Formulir;
use Illuminate\Auth\Access\HandlesAuthorization;
class FormulirPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_formulir');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Formulir $formulir): bool
{
return $user->can('view_formulir');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_formulir');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Formulir $formulir): bool
{
return $user->can('update_formulir');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Formulir $formulir): bool
{
return $user->can('delete_formulir');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_formulir');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Formulir $formulir): bool
{
return $user->can('force_delete_formulir');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_formulir');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Formulir $formulir): bool
{
return $user->can('restore_formulir');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_formulir');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Formulir $formulir): bool
{
return $user->can('replicate_formulir');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_formulir');
}
}

View File

@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Kriteria;
use Illuminate\Auth\Access\HandlesAuthorization;
class KriteriaPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_kriteria');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Kriteria $kriteria): bool
{
return $user->can('view_kriteria');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_kriteria');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Kriteria $kriteria): bool
{
return $user->can('update_kriteria');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Kriteria $kriteria): bool
{
return $user->can('delete_kriteria');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_kriteria');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Kriteria $kriteria): bool
{
return $user->can('force_delete_kriteria');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_kriteria');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Kriteria $kriteria): bool
{
return $user->can('restore_kriteria');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_kriteria');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Kriteria $kriteria): bool
{
return $user->can('replicate_kriteria');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_kriteria');
}
}

View File

@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Mahasiswa;
use Illuminate\Auth\Access\HandlesAuthorization;
class MahasiswaPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_mahasiswa');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Mahasiswa $mahasiswa): bool
{
return $user->can('view_mahasiswa');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_mahasiswa');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Mahasiswa $mahasiswa): bool
{
return $user->can('update_mahasiswa');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Mahasiswa $mahasiswa): bool
{
return $user->can('delete_mahasiswa');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_mahasiswa');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Mahasiswa $mahasiswa): bool
{
return $user->can('force_delete_mahasiswa');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_mahasiswa');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Mahasiswa $mahasiswa): bool
{
return $user->can('restore_mahasiswa');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_mahasiswa');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Mahasiswa $mahasiswa): bool
{
return $user->can('replicate_mahasiswa');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_mahasiswa');
}
}

View File

@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\SubKriteria;
use Illuminate\Auth\Access\HandlesAuthorization;
class SubKriteriaPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_sub::kriteria');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, SubKriteria $subKriteria): bool
{
return $user->can('view_sub::kriteria');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_sub::kriteria');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, SubKriteria $subKriteria): bool
{
return $user->can('update_sub::kriteria');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, SubKriteria $subKriteria): bool
{
return $user->can('delete_sub::kriteria');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_sub::kriteria');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, SubKriteria $subKriteria): bool
{
return $user->can('force_delete_sub::kriteria');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_sub::kriteria');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, SubKriteria $subKriteria): bool
{
return $user->can('restore_sub::kriteria');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_sub::kriteria');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, SubKriteria $subKriteria): bool
{
return $user->can('replicate_sub::kriteria');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_sub::kriteria');
}
}

View File

@ -0,0 +1,116 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Parameter;
use Illuminate\Auth\Access\HandlesAuthorization;
class ParameterPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_pengumuman');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Parameter $parameter): bool
{
return $user->can('view_pengumuman');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_pengumuman');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Parameter $parameter): bool
{
return $user->can('update_pengumuman');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Parameter $parameter): bool
{
return $user->can('delete_pengumuman');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_pengumuman');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Parameter $parameter): bool
{
return $user->can('force_delete_pengumuman');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_pengumuman');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Parameter $parameter): bool
{
return $user->can('restore_pengumuman');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_pengumuman');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Parameter $parameter): bool
{
return $user->can('replicate_pengumuman');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_pengumuman');
}
public function show()
{
$pengumuman = Parameter::where('mahasiswa_id', auth()->user()->mahasiswa->id)
->first();
return view('pengumuman', compact('pengumuman'));
}
}

View File

@ -20,6 +20,7 @@
use Illuminate\View\Middleware\ShareErrorsFromSession;
use App\Filament\Pages\WizardForm;
use App\Filament\Widgets\CustomAccountWidget;
use App\Filament\Pages\Auth\Register;
class AdminPanelProvider extends PanelProvider
{
@ -30,6 +31,7 @@ public function panel(Panel $panel): Panel
->id('admin')
->path('admin')
->login()
->registration(Register::class)
->plugin(FilamentShieldPlugin::make())
->brandLogo(asset('images/logo-polije.png'))
->brandLogoHeight('3rem')

View File

@ -0,0 +1,21 @@
<x-filament-panels::page>
<div class="space-y-6">
<div class="bg-white rounded-lg shadow p-6">
<h2 class="text-2xl font-bold mb-4">Selamat Datang di Sistem KIP-K</h2>
<p class="text-gray-600">
Sistem ini digunakan untuk pendaftaran dan pengelolaan Kartu Indonesia Pintar Kuliah (KIP-K).
Silakan gunakan menu navigasi di sebelah kiri untuk mengakses fitur-fitur yang tersedia.
</p>
</div>
<div class="bg-white rounded-lg shadow p-6">
<h3 class="text-xl font-semibold mb-4">Informasi Penting</h3>
<ul class="list-disc list-inside space-y-2 text-gray-600">
<li>Pastikan data diri Anda sudah lengkap dan valid</li>
<li>Lengkapi semua berkas yang diperlukan sesuai dengan persyaratan</li>
<li>Periksa status pengajuan Anda secara berkala</li>
<li>Jika ada kendala, silakan hubungi admin</li>
</ul>
</div>
</div>
</x-filament-panels::page>

View File

@ -0,0 +1,12 @@
<x-filament-panels::page>
<div class="space-y-6">
<div class="bg-white rounded-lg shadow p-6">
<h2 class="text-2xl font-bold mb-4">Form Pendaftaran KIP-K</h2>
<p class="text-gray-600 mb-4">
Silakan lengkapi form pendaftaran berikut untuk mengajukan KIP-K. Pastikan semua data yang Anda masukkan valid dan lengkap.
</p>
<livewire:wizard-form />
</div>
</div>
</x-filament-panels::page>

View File

@ -0,0 +1,12 @@
<x-filament-panels::page>
<div class="space-y-6">
<div class="bg-white rounded-lg shadow p-6">
<h2 class="text-2xl font-bold mb-4">Pengumuman Hasil Seleksi KIP-K</h2>
<p class="text-gray-600 mb-4">
Berikut adalah status pengajuan dan hasil seleksi KIP-K Anda. Silakan periksa secara berkala untuk mendapatkan informasi terbaru.
</p>
{{ $this->table }}
</div>
</div>
</x-filament-panels::page>