Initial commit
This commit is contained in:
parent
120ffbe865
commit
d9f69b7f68
|
@ -0,0 +1,223 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\ListformResource\Pages;
|
||||
use App\Models\Listform;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Actions\ViewAction;
|
||||
use Filament\Forms\Components\ViewField;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ListformResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Listform::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-clipboard-document-list';
|
||||
protected static ?string $navigationGroup = 'Penilaian';
|
||||
protected static ?string $navigationLabel = 'Form Penilaian KIP-K';
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make('Data Mahasiswa')
|
||||
->schema([
|
||||
Select::make('mahasiswa_id')
|
||||
->relationship('mahasiswa', 'nama')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required()
|
||||
->label('Nama Mahasiswa'),
|
||||
]),
|
||||
|
||||
Section::make('Kepemilikan KIP')
|
||||
->schema([
|
||||
Select::make('kepemilikan_kip')
|
||||
->options([
|
||||
'Memiliki KIP' => 'Memiliki KIP',
|
||||
'Tidak Memiliki KIP' => 'Tidak Memiliki KIP',
|
||||
])
|
||||
->required(),
|
||||
]),
|
||||
|
||||
Section::make('Tingkatan Desil')
|
||||
->schema([
|
||||
Select::make('tingkatan_desil')
|
||||
->options([
|
||||
'Desil 1' => 'Desil 1',
|
||||
'Desil 2' => 'Desil 2',
|
||||
'Desil 3' => 'Desil 3',
|
||||
'Desil 4' => 'Desil 4',
|
||||
'Desil 5' => 'Desil 5',
|
||||
])
|
||||
->required(),
|
||||
]),
|
||||
|
||||
Section::make('Upload Berkas Pendukung')
|
||||
->schema([
|
||||
FileUpload::make('berkas_sktm')
|
||||
->label('Upload SKTM')
|
||||
->helperText('Surat Keterangan Tidak Mampu dari Kelurahan/Desa')
|
||||
->directory('berkas-sktm')
|
||||
->preserveFilenames()
|
||||
->required()
|
||||
->acceptedFileTypes(['application/pdf']),
|
||||
|
||||
FileUpload::make('berkas_ppke')
|
||||
->label('Upload PPKE')
|
||||
->helperText('Pernyataan Penghasilan Keluarga')
|
||||
->directory('berkas-ppke')
|
||||
->preserveFilenames()
|
||||
->acceptedFileTypes(['application/pdf']),
|
||||
|
||||
FileUpload::make('berkas_pmk')
|
||||
->label('Upload PMK')
|
||||
->helperText('Pernyataan Mahasiswa Kurang Mampu')
|
||||
->directory('berkas-pmk')
|
||||
->preserveFilenames()
|
||||
->acceptedFileTypes(['application/pdf']),
|
||||
|
||||
FileUpload::make('berkas_pkh')
|
||||
->label('Upload PKH')
|
||||
->helperText('Kartu Program Keluarga Harapan')
|
||||
->directory('berkas-pkh')
|
||||
->preserveFilenames()
|
||||
->acceptedFileTypes(['application/pdf']),
|
||||
|
||||
FileUpload::make('berkas_kks')
|
||||
->label('Upload KKS')
|
||||
->helperText('Kartu Keluarga Sejahtera')
|
||||
->directory('berkas-kks')
|
||||
->preserveFilenames()
|
||||
->acceptedFileTypes(['application/pdf']),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('mahasiswa.nama')
|
||||
->label('Nama Mahasiswa')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('kepemilikan_kip')
|
||||
->label('Kepemilikan KIP'),
|
||||
TextColumn::make('tingkatan_desil')
|
||||
->label('Tingkatan Desil'),
|
||||
TextColumn::make('kondisi_ekonomi')
|
||||
->label('Kondisi Ekonomi'),
|
||||
TextColumn::make('total_nilai')
|
||||
->label('Total Nilai')
|
||||
->sortable(),
|
||||
TextColumn::make('status')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'submitted' => 'success',
|
||||
'draft' => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
])
|
||||
->defaultSort('total_nilai', 'desc')
|
||||
->filters([])
|
||||
->actions([
|
||||
ViewAction::make()
|
||||
->form([
|
||||
Section::make('Data Mahasiswa')
|
||||
->schema([
|
||||
TextInput::make('mahasiswa_name')
|
||||
->label('Nama Mahasiswa')
|
||||
->formatStateUsing(fn ($record) => $record->mahasiswa->nama)
|
||||
->disabled(),
|
||||
TextInput::make('kepemilikan_kip')
|
||||
->label('Kepemilikan KIP')
|
||||
->disabled(),
|
||||
TextInput::make('tingkatan_desil')
|
||||
->label('Tingkatan Desil')
|
||||
->disabled(),
|
||||
TextInput::make('kondisi_ekonomi')
|
||||
->label('Kondisi Ekonomi')
|
||||
->disabled(),
|
||||
TextInput::make('total_nilai')
|
||||
->label('Total Nilai')
|
||||
->disabled(),
|
||||
]),
|
||||
Section::make('Berkas')
|
||||
->schema([
|
||||
Placeholder::make('berkas_sktm')
|
||||
->label('SKTM')
|
||||
->content(fn ($record) => $record->berkas_sktm ?
|
||||
view('filament.components.file-link', [
|
||||
'url' => Storage::url($record->berkas_sktm),
|
||||
'label' => 'SKTM'
|
||||
]) :
|
||||
'Tidak ada berkas'
|
||||
),
|
||||
Placeholder::make('berkas_ppke')
|
||||
->label('PPKE')
|
||||
->content(fn ($record) => $record->berkas_ppke ?
|
||||
view('filament.components.file-link', [
|
||||
'url' => Storage::url($record->berkas_ppke),
|
||||
'label' => 'PPKE'
|
||||
]) :
|
||||
'Tidak ada berkas'
|
||||
),
|
||||
Placeholder::make('berkas_pmk')
|
||||
->label('PMK')
|
||||
->content(fn ($record) => $record->berkas_pmk ?
|
||||
view('filament.components.file-link', [
|
||||
'url' => Storage::url($record->berkas_pmk),
|
||||
'label' => 'PMK'
|
||||
]) :
|
||||
'Tidak ada berkas'
|
||||
),
|
||||
Placeholder::make('berkas_pkh')
|
||||
->label('PKH')
|
||||
->content(fn ($record) => $record->berkas_pkh ?
|
||||
view('filament.components.file-link', [
|
||||
'url' => Storage::url($record->berkas_pkh),
|
||||
'label' => 'PKH'
|
||||
]) :
|
||||
'Tidak ada berkas'
|
||||
),
|
||||
Placeholder::make('berkas_kks')
|
||||
->label('KKS')
|
||||
->content(fn ($record) => $record->berkas_kks ?
|
||||
view('filament.components.file-link', [
|
||||
'url' => Storage::url($record->berkas_kks),
|
||||
'label' => 'KKS'
|
||||
]) :
|
||||
'Tidak ada berkas'
|
||||
),
|
||||
]),
|
||||
]),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListListforms::route('/'),
|
||||
'create' => Pages\CreateListform::route('/create'),
|
||||
'edit' => Pages\EditListform::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ListformResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ListformResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateListform extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ListformResource::class;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ListformResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ListformResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditListform extends EditRecord
|
||||
{
|
||||
protected static string $resource = ListformResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ListformResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ListformResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListListforms extends ListRecords
|
||||
{
|
||||
protected static string $resource = ListformResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Listform extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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++;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Tambahkan nilai kondisi ekonomi
|
||||
$totalNilai += $listform->nilai_kondisi_ekonomi;
|
||||
|
||||
$listform->total_nilai = $totalNilai;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -40,6 +40,7 @@ public function panel(Panel $panel): Panel
|
|||
Widgets\AccountWidget::class,
|
||||
Widgets\FilamentInfoWidget::class,
|
||||
])
|
||||
->spa()
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('listforms', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('mahasiswa_id')->constrained('mahasiswas')->cascadeOnDelete();
|
||||
|
||||
// Untuk Kriteria 1: Kepemilikan KIP
|
||||
$table->enum('kepemilikan_kip', ['Memiliki KIP', 'Tidak Memiliki KIP']);
|
||||
|
||||
// Untuk Kriteria 2: Tingkatan Desil
|
||||
$table->enum('tingkatan_desil', [
|
||||
'Desil 1',
|
||||
'Desil 2',
|
||||
'Desil 3',
|
||||
'Desil 4',
|
||||
'Desil 5'
|
||||
]);
|
||||
|
||||
// Untuk Kriteria 3: Kondisi Ekonomi
|
||||
$table->enum('kondisi_ekonomi', ['Sangat Kurang Mampu', 'Kurang Mampu', 'Cukup Mampu']);
|
||||
|
||||
// Berkas untuk Kondisi Ekonomi
|
||||
$table->string('berkas_sktm')->nullable(); // Untuk semua kondisi
|
||||
$table->string('berkas_ppke')->nullable(); // Untuk Kurang Mampu & Sangat Kurang Mampu
|
||||
$table->string('berkas_pmk')->nullable(); // Untuk Kurang Mampu & Sangat Kurang Mampu
|
||||
$table->string('berkas_pkh')->nullable(); // Khusus Sangat Kurang Mampu
|
||||
$table->string('berkas_kks')->nullable(); // Khusus Sangat Kurang Mampu
|
||||
|
||||
// Untuk menyimpan nilai perhitungan
|
||||
$table->decimal('nilai_kepemilikan_kip', 10, 7)->default(0);
|
||||
$table->decimal('nilai_tingkatan_desil', 10, 7)->default(0);
|
||||
$table->decimal('nilai_kondisi_ekonomi', 10, 7)->default(0);
|
||||
$table->decimal('total_nilai', 10, 7)->default(0);
|
||||
|
||||
// Status form
|
||||
$table->enum('status', ['draft', 'submitted'])->default('draft');
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('listforms');
|
||||
}
|
||||
};
|
|
@ -36,21 +36,35 @@ public function run(): void
|
|||
'nama' => 'Desil 1',
|
||||
'deskripsi' => 'Tingkat kesejahteraan terendah',
|
||||
'prioritas' => 1,
|
||||
'bobot' => 0.4,
|
||||
'bobot' => 0.35,
|
||||
],
|
||||
[
|
||||
'kriteria_id' => 2,
|
||||
'nama' => 'Desil 2',
|
||||
'deskripsi' => 'Tingkat kesejahteraan rendah',
|
||||
'deskripsi' => 'Tingkat kesejahteraan sangat rendah',
|
||||
'prioritas' => 2,
|
||||
'bobot' => 0.3,
|
||||
'bobot' => 0.25,
|
||||
],
|
||||
[
|
||||
'kriteria_id' => 2,
|
||||
'nama' => 'Desil 3',
|
||||
'deskripsi' => 'Tingkat kesejahteraan menengah bawah',
|
||||
'deskripsi' => 'Tingkat kesejahteraan rendah',
|
||||
'prioritas' => 3,
|
||||
'bobot' => 0.3,
|
||||
'bobot' => 0.20,
|
||||
],
|
||||
[
|
||||
'kriteria_id' => 2,
|
||||
'nama' => 'Desil 4',
|
||||
'deskripsi' => 'Tingkat kesejahteraan menengah bawah',
|
||||
'prioritas' => 4,
|
||||
'bobot' => 0.15,
|
||||
],
|
||||
[
|
||||
'kriteria_id' => 2,
|
||||
'nama' => 'Desil 5',
|
||||
'deskripsi' => 'Tingkat kesejahteraan menengah',
|
||||
'prioritas' => 5,
|
||||
'bobot' => 0.05,
|
||||
],
|
||||
|
||||
// Subkriteria untuk Kondisi Ekonomi (kriteria_id: 3)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
@if($url)
|
||||
<div>
|
||||
<a href="{{ $url }}" target="_blank" class="text-primary-600 hover:text-primary-500">
|
||||
Lihat {{ $label }}
|
||||
</a>
|
||||
</div>
|
||||
@else
|
||||
<div class="text-gray-500">
|
||||
Tidak ada berkas
|
||||
</div>
|
||||
@endif
|
|
@ -0,0 +1,3 @@
|
|||
<x-filament-panels::page>
|
||||
|
||||
</x-filament-panels::page>
|
Loading…
Reference in New Issue