Update Koperasi

This commit is contained in:
2026-11-06 22:38:45 +07:00
parent 6232b28e11
commit cb36682d9e
79 changed files with 4639 additions and 1378 deletions
@@ -0,0 +1,37 @@
<?php
namespace App\Http\Requests\Koperasi;
use App\Models\Koperasi\PengurusKoperasi;
abstract class KoperasiTabRequest extends KoperasiRequest
{
public function authorize(): bool
{
$pengurus = $this->route('pengurusKoperasi');
return $pengurus instanceof PengurusKoperasi && $pengurus->profilLengkap();
}
public function attributes(): array
{
$attributes = [];
foreach (array_keys($this->rules()) as $field) {
$attributes[$field] = ucfirst(str_replace(['_', '.*'], [' ', ''], $field));
}
return $attributes;
}
protected function prepareForValidation(): void
{
parent::prepareForValidation();
// Checkbox yang dikosongkan harus menghapus pilihan yang sebelumnya tersimpan.
foreach ($this->rules() as $field => $rules) {
if (in_array('array', $rules, true) && ! $this->exists($field)) {
$this->merge([$field => []]);
}
}
}
}