fixing widget pendaftar
This commit is contained in:
parent
00cd727ac4
commit
f59f93b885
|
@ -13,7 +13,7 @@ public function getWidgets(): array
|
|||
{
|
||||
/** @var User $user */
|
||||
$user = Auth::user();
|
||||
if ($user->hasRole('Mahasiswa')) { {
|
||||
if ($user->hasRole('mahasiswa')) { {
|
||||
return [
|
||||
\App\Filament\Widgets\CustomAccountWidget::class,
|
||||
];
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Parameter;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Infolists\Infolist;
|
||||
use Filament\Infolists\Components\Section;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Infolists\Components\Grid;
|
||||
use Filament\Navigation\NavigationItem;
|
||||
|
||||
class ProgresDataPage extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
protected static ?string $navigationLabel = 'Info';
|
||||
protected static ?string $navigationGroup = 'Mahasiswa';
|
||||
protected static ?int $navigationSort = 1;
|
||||
protected static string $view = 'filament.pages.progres-data-page';
|
||||
protected static string $routePath = 'progres';
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Info';
|
||||
}
|
||||
|
||||
public function infolist(Infolist $infolist): Infolist
|
||||
{
|
||||
$user = auth()->user();
|
||||
$data = Parameter::where('mahasiswa_id', $user->id)->first();
|
||||
|
||||
return $infolist
|
||||
->schema([
|
||||
Section::make('Status Berkas')
|
||||
->schema([
|
||||
Grid::make(2)
|
||||
->schema([
|
||||
TextEntry::make('status')
|
||||
->label('Status Berkas')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'valid' => 'success',
|
||||
'tidak_valid' => 'danger',
|
||||
'belum_validasi' => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('hasil')
|
||||
->label('Hasil Seleksi')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'Layak' => 'success',
|
||||
'Dipertimbangkan' => 'warning',
|
||||
'Tidak Layak' => 'danger',
|
||||
default => 'gray',
|
||||
}),
|
||||
]),
|
||||
]),
|
||||
Section::make('Keterangan')
|
||||
->schema([
|
||||
TextEntry::make('keterangan')
|
||||
->label('Informasi Progres')
|
||||
->markdown()
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
])
|
||||
->state([
|
||||
'status' => $data?->status ?? 'belum_validasi',
|
||||
'hasil' => $data?->hasil ?? 'Belum Ada Hasil',
|
||||
'keterangan' => $data?->keterangan ?? 'Data Anda sedang dalam proses validasi',
|
||||
]);
|
||||
}
|
||||
|
||||
public static function shouldRegisterNavigation(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getNavigationItems(): array
|
||||
{
|
||||
return [
|
||||
NavigationItem::make('Info')
|
||||
->url(fn (): string => static::getUrl())
|
||||
->icon('heroicon-o-document-text')
|
||||
->isActiveWhen(fn (): bool => request()->routeIs(static::getRouteName()))
|
||||
->visible(fn (): bool => auth()->check() && auth()->user()->roles[0]->name == 'Mahasiswa'),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -32,6 +32,18 @@ class WizardForm extends Page
|
|||
|
||||
public function mount(): void
|
||||
{
|
||||
// Cek apakah mahasiswa sudah pernah mengisi form
|
||||
$mahasiswa = Mahasiswa::where('user_id', auth()->id())->first();
|
||||
if ($mahasiswa && $mahasiswa->parameter) {
|
||||
Notification::make()
|
||||
->warning()
|
||||
->title('Peringatan')
|
||||
->body('Anda sudah pernah mengisi form pendaftaran KIP-K')
|
||||
->send();
|
||||
|
||||
$this->redirect('/admin/');
|
||||
}
|
||||
|
||||
$this->form->fill();
|
||||
}
|
||||
|
||||
|
@ -216,6 +228,7 @@ public function submit()
|
|||
try {
|
||||
// Simpan data mahasiswa
|
||||
$mahasiswa = Mahasiswa::create([
|
||||
'user_id' => auth()->id(),
|
||||
'noreg_kipk' => $data['noreg_kipk'],
|
||||
'nama' => $data['nama'],
|
||||
'nim' => $data['nim'],
|
||||
|
@ -254,7 +267,7 @@ public function submit()
|
|||
->body('Data berhasil disimpan')
|
||||
->send();
|
||||
|
||||
$this->redirect('/admin/parameters');
|
||||
$this->redirect('/admin/');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
|
|
|
@ -17,15 +17,22 @@
|
|||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class FormulirResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Formulir::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-clipboard-document';
|
||||
protected static ?string $navigationGroup = 'Data Master';
|
||||
protected static ?string $slug = 'daftar-formulir';
|
||||
protected static ?int $navigationSort = 5;
|
||||
protected static ?string $slug = 'daftar-formulir';
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return auth()->user()->roles[0]->name === 'mahasiswa'
|
||||
? null
|
||||
: 'Data Master';
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
|
@ -74,6 +81,13 @@ public static function table(Table $table): Table
|
|||
->url(fn (Formulir $record): string => '/admin/wizard-form')
|
||||
->openUrlInNewTab(false)
|
||||
->visible(fn (Formulir $record): bool => $record->status === 'dibuka'),
|
||||
Action::make('info')
|
||||
->label('Info')
|
||||
->icon('heroicon-o-information-circle')
|
||||
->color('warning')
|
||||
->url(fn (): string => '/admin/progres-data-page')
|
||||
->openUrlInNewTab(false)
|
||||
->visible(fn (): bool => Auth::user()->hasRole('mahasiswa')),
|
||||
Action::make('toggleStatus')
|
||||
->label(fn (Formulir $record): string => $record->status === 'dibuka' ? 'Tutup' : 'Buka')
|
||||
->icon(fn (Formulir $record): string => $record->status === 'dibuka' ? 'heroicon-o-x-circle' : 'heroicon-o-check-circle')
|
||||
|
@ -82,7 +96,8 @@ public static function table(Table $table): Table
|
|||
$record->update([
|
||||
'status' => $record->status === 'dibuka' ? 'ditutup' : 'dibuka'
|
||||
]);
|
||||
}),
|
||||
})
|
||||
->visible(fn (): bool => Auth::user()->hasRole('super_admin')),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
use Filament\Tables\Table;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ViewColumn;
|
||||
use Illuminate\Database\Eloquent\Builder; // Add this line
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class PengumumanResource extends Resource
|
||||
{
|
||||
|
|
|
@ -16,10 +16,11 @@ protected function getStats(): array
|
|||
return [
|
||||
Stat::make('Kriteria', Kriteria::count()),
|
||||
Stat::make('SubKriteria', Subkriteria::count()),
|
||||
Stat::make('Jumlah Pendaftar', Mahasiswa::count())
|
||||
Stat::make('Jumlah Pendaftar', Mahasiswa::has('parameter')->count())
|
||||
->description('Total Mahasiswa yang telah mendaftar')
|
||||
->color('info')
|
||||
->chart(Mahasiswa::selectRaw('DATE(created_at) as date, COUNT(*) as total')
|
||||
->chart(Mahasiswa::has('parameter')
|
||||
->selectRaw('DATE(created_at) as date, COUNT(*) as total')
|
||||
->groupBy('date')
|
||||
->orderBy('date')
|
||||
->pluck('total')
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Pengumuman extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'pengumumans';
|
||||
|
||||
protected $fillable = [
|
||||
'parameter_id',
|
||||
'user_id',
|
||||
'keterangan'
|
||||
];
|
||||
|
||||
public function parameter(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Parameter::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
|
@ -10,4 +10,9 @@ class Mahasiswa extends Model
|
|||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function parameter()
|
||||
{
|
||||
return $this->hasOne(Parameter::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
'shield_resource' => [
|
||||
'should_register_navigation' => true,
|
||||
'slug' => 'shield/roles',
|
||||
'navigation_sort' => -1,
|
||||
'navigation_sort' => 4,
|
||||
'navigation_badge' => true,
|
||||
'navigation_group' => true,
|
||||
'is_globally_searchable' => false,
|
||||
|
|
|
@ -13,6 +13,7 @@ public function up(): void
|
|||
{
|
||||
Schema::create('mahasiswas', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->string('noreg_kipk');
|
||||
$table->string('nama');
|
||||
$table->string('NIM');
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('pengumumans', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('parameter_id')->constrained('parameters')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->text('keterangan')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('pengumumans');
|
||||
}
|
||||
};
|
|
@ -17,7 +17,7 @@ public function run(): void
|
|||
KriteriaSeeder::class,
|
||||
SubKriteriaSeeder::class,
|
||||
MahasiswaSeeder::class,
|
||||
SuperAdminPermissionSeeder::class,
|
||||
// SuperAdminPermissionSeeder::class,
|
||||
PermissionSeeder::class,
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Mahasiswa;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
|
@ -13,6 +14,9 @@ class MahasiswaSeeder extends Seeder
|
|||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Ambil user dengan role mahasiswa
|
||||
$users = User::role('mahasiswa')->get();
|
||||
|
||||
$mahasiswas = [
|
||||
[
|
||||
'noreg_kipk' => 'KIP001',
|
||||
|
@ -52,8 +56,12 @@ public function run(): void
|
|||
],
|
||||
];
|
||||
|
||||
foreach ($mahasiswas as $mahasiswa) {
|
||||
Mahasiswa::create($mahasiswa);
|
||||
foreach ($users as $index => $user) {
|
||||
if (isset($mahasiswas[$index])) {
|
||||
Mahasiswa::create(array_merge($mahasiswas[$index], [
|
||||
'user_id' => $user->id
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PermissionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Hapus semua data yang terkait dengan permission dan role
|
||||
DB::table('model_has_permissions')->delete();
|
||||
DB::table('model_has_roles')->delete();
|
||||
DB::table('role_has_permissions')->delete();
|
||||
DB::table('permissions')->delete();
|
||||
DB::table('roles')->delete();
|
||||
|
||||
// Permission untuk Parameter
|
||||
$parameterPermissions = [
|
||||
'view_any_parameter',
|
||||
'view_parameter',
|
||||
'create_parameter',
|
||||
'update_parameter',
|
||||
'delete_parameter',
|
||||
'delete_any_parameter',
|
||||
'force_delete_parameter',
|
||||
'force_delete_any_parameter',
|
||||
'restore_parameter',
|
||||
'restore_any_parameter',
|
||||
'replicate_parameter',
|
||||
'reorder_parameter'
|
||||
];
|
||||
|
||||
// Permission untuk Hasil
|
||||
$hasilPermissions = [
|
||||
'view_any_hasil',
|
||||
'view_hasil',
|
||||
'create_hasil',
|
||||
'update_hasil',
|
||||
'delete_hasil',
|
||||
'delete_any_hasil',
|
||||
'force_delete_hasil',
|
||||
'force_delete_any_hasil',
|
||||
'restore_hasil',
|
||||
'restore_any_hasil',
|
||||
'replicate_hasil',
|
||||
'reorder_hasil'
|
||||
];
|
||||
|
||||
// Permission untuk Pengumuman
|
||||
$pengumumanPermissions = [
|
||||
'view_any_pengumuman',
|
||||
'view_pengumuman',
|
||||
'create_pengumuman',
|
||||
'update_pengumuman',
|
||||
'delete_pengumuman',
|
||||
'delete_any_pengumuman',
|
||||
'force_delete_pengumuman',
|
||||
'force_delete_any_pengumuman',
|
||||
'restore_pengumuman',
|
||||
'restore_any_pengumuman',
|
||||
'replicate_pengumuman',
|
||||
'reorder_pengumuman'
|
||||
];
|
||||
|
||||
// Permission untuk Mahasiswa
|
||||
$mahasiswaPermissions = [
|
||||
'view_any_mahasiswa',
|
||||
'view_mahasiswa',
|
||||
'create_mahasiswa',
|
||||
'update_mahasiswa',
|
||||
'delete_mahasiswa',
|
||||
'delete_any_mahasiswa',
|
||||
'force_delete_mahasiswa',
|
||||
'force_delete_any_mahasiswa',
|
||||
'restore_mahasiswa',
|
||||
'restore_any_mahasiswa',
|
||||
'replicate_mahasiswa',
|
||||
'reorder_mahasiswa'
|
||||
];
|
||||
|
||||
// Permission untuk Kriteria
|
||||
$kriteriaPermissions = [
|
||||
'view_any_kriteria',
|
||||
'view_kriteria',
|
||||
'create_kriteria',
|
||||
'update_kriteria',
|
||||
'delete_kriteria',
|
||||
'delete_any_kriteria',
|
||||
'force_delete_kriteria',
|
||||
'force_delete_any_kriteria',
|
||||
'restore_kriteria',
|
||||
'restore_any_kriteria',
|
||||
'replicate_kriteria',
|
||||
'reorder_kriteria'
|
||||
];
|
||||
|
||||
// Permission untuk SubKriteria
|
||||
$subKriteriaPermissions = [
|
||||
'view_any_subkriteria',
|
||||
'view_subkriteria',
|
||||
'create_subkriteria',
|
||||
'update_subkriteria',
|
||||
'delete_subkriteria',
|
||||
'delete_any_subkriteria',
|
||||
'force_delete_subkriteria',
|
||||
'force_delete_any_subkriteria',
|
||||
'restore_subkriteria',
|
||||
'restore_any_subkriteria',
|
||||
'replicate_subkriteria',
|
||||
'reorder_subkriteria'
|
||||
];
|
||||
|
||||
// Gabungkan semua permission
|
||||
$allPermissions = array_merge(
|
||||
$parameterPermissions,
|
||||
$hasilPermissions,
|
||||
$pengumumanPermissions,
|
||||
$mahasiswaPermissions,
|
||||
$kriteriaPermissions,
|
||||
$subKriteriaPermissions
|
||||
);
|
||||
|
||||
// Buat permission
|
||||
foreach ($allPermissions as $permission) {
|
||||
Permission::create(['name' => $permission]);
|
||||
}
|
||||
|
||||
// Buat role Super Admin dan berikan semua permission
|
||||
$superAdmin = Role::create(['name' => 'super_admin']);
|
||||
$superAdmin->syncPermissions($allPermissions);
|
||||
|
||||
// Buat role Admin dan berikan permission yang diperlukan
|
||||
$admin = Role::create(['name' => 'admin']);
|
||||
$admin->syncPermissions(array_merge(
|
||||
$parameterPermissions,
|
||||
$hasilPermissions,
|
||||
$pengumumanPermissions
|
||||
));
|
||||
|
||||
// Buat role Mahasiswa dan berikan permission yang diperlukan
|
||||
$mahasiswa = Role::create(['name' => 'mahasiswa']);
|
||||
$mahasiswa->syncPermissions($pengumumanPermissions);
|
||||
}
|
||||
}
|
|
@ -13,22 +13,38 @@ class UserSeeder extends Seeder
|
|||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Hapus data yang sudah ada jika ingin fresh data
|
||||
User::truncate();
|
||||
// Buat Super Admin
|
||||
$superAdmin = User::create([
|
||||
'name' => 'Admin',
|
||||
'email' => 'pengelola@admin.com',
|
||||
'password' => Hash::make('12345678'),
|
||||
'email_verified_at' => now()
|
||||
]);
|
||||
$superAdmin->assignRole('super_admin');
|
||||
|
||||
// Cek apakah email sudah ada
|
||||
if (!User::where('email', 'najwa@admin.com')->exists()) {
|
||||
$user = User::create([
|
||||
'name' => 'Najwa',
|
||||
'email' => 'najwa@admin.com',
|
||||
// Buat Admin
|
||||
$admin = User::create([
|
||||
'name' => 'Admin',
|
||||
'email' => 'admin@admin.com',
|
||||
'password' => Hash::make('12345678'),
|
||||
'email_verified_at' => now()
|
||||
]);
|
||||
$admin->assignRole('admin');
|
||||
|
||||
// Buat beberapa mahasiswa
|
||||
$mahasiswas = [
|
||||
[
|
||||
'name' => 'Ahmad Fauzi',
|
||||
'email' => 'ahmad@user.com',
|
||||
'password' => Hash::make('12345678'),
|
||||
'email_verified_at' => now()
|
||||
]);
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
// Berikan role super_admin
|
||||
$user->assignRole('super_admin');
|
||||
foreach ($mahasiswas as $mahasiswa) {
|
||||
$user = User::create($mahasiswa);
|
||||
$user->assignRole('mahasiswa');
|
||||
}
|
||||
|
||||
// Tambahkan user lain jika diperlukan
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<x-filament-panels::page>
|
||||
<div class="space-y-6">
|
||||
<div class="bg-white rounded-xl shadow-sm p-6">
|
||||
<h2 class="text-lg font-medium text-gray-900 mb-4">Informasi Status</h2>
|
||||
{{ $this->infolist }}
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl shadow-sm p-6">
|
||||
<h2 class="text-lg font-medium text-gray-900 mb-4">Status Progres</h2>
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-center space-x-2">
|
||||
<div class="h-2 w-2 rounded-full bg-blue-500"></div>
|
||||
<span class="text-sm text-gray-600">Data Anda sedang dalam proses validasi</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<div class="h-2 w-2 rounded-full bg-yellow-500"></div>
|
||||
<span class="text-sm text-gray-600">Tim akan memeriksa kelengkapan dokumen Anda</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<div class="h-2 w-2 rounded-full bg-green-500"></div>
|
||||
<span class="text-sm text-gray-600">Hasil seleksi akan diumumkan sesuai jadwal</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-filament-panels::page>
|
|
@ -0,0 +1,26 @@
|
|||
<x-filament-panels::page>
|
||||
<div class="space-y-6">
|
||||
<div class="bg-white rounded-xl shadow-sm p-6">
|
||||
<h2 class="text-lg font-medium text-gray-900 mb-4">Informasi Progres Data</h2>
|
||||
{{ $this->infolist }}
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl shadow-sm p-6">
|
||||
<h2 class="text-lg font-medium text-gray-900 mb-4">Status Progres</h2>
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-center space-x-2">
|
||||
<div class="h-2 w-2 rounded-full bg-blue-500"></div>
|
||||
<span class="text-sm text-gray-600">Data Anda sedang dalam proses validasi</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<div class="h-2 w-2 rounded-full bg-yellow-500"></div>
|
||||
<span class="text-sm text-gray-600">Tim akan memeriksa kelengkapan dokumen Anda</span>
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<div class="h-2 w-2 rounded-full bg-green-500"></div>
|
||||
<span class="text-sm text-gray-600">Hasil seleksi akan diumumkan sesuai jadwal</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-filament-panels::page>
|
Loading…
Reference in New Issue