feat: pindah route ke /dashboard, tambah seeders, business rules via observers, action verifikasi & approval
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Activity;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ActivitySeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$pengurus = User::role('pengurus')->first();
|
||||
$ketua = User::role('ketua')->first();
|
||||
$anggota = User::role('anggota')->get();
|
||||
|
||||
$activities = [
|
||||
[
|
||||
'title' => 'Kerja Bakti Desa',
|
||||
'description' => 'Kegiatan bersih-bersih lingkungan desa',
|
||||
'start_date' => now()->addDays(7),
|
||||
'end_date' => now()->addDays(7),
|
||||
'status' => 'approved',
|
||||
'approved_by' => $ketua?->id,
|
||||
'approved_at' => now(),
|
||||
],
|
||||
[
|
||||
'title' => 'Pelatihan Kewirausahaan',
|
||||
'description' => 'Pelatihan usaha kecil untuk pemuda desa',
|
||||
'start_date' => now()->addDays(14),
|
||||
'end_date' => now()->addDays(15),
|
||||
'status' => 'pending',
|
||||
],
|
||||
[
|
||||
'title' => 'Turnamen Voli Antar RT',
|
||||
'description' => 'Kompetisi voli untuk mempererat silaturahmi',
|
||||
'start_date' => now()->subDays(10),
|
||||
'end_date' => now()->subDays(8),
|
||||
'status' => 'approved',
|
||||
'approved_by' => $ketua?->id,
|
||||
'approved_at' => now()->subDays(15),
|
||||
'executed_at' => now()->subDays(10),
|
||||
'execution_notes' => 'Kegiatan berjalan lancar, diikuti 8 tim.',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($activities as $data) {
|
||||
$activity = Activity::create(array_merge($data, ['created_by' => $pengurus?->id]));
|
||||
$activity->participants()->sync($anggota->pluck('id'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\CashCategory;
|
||||
use App\Models\CashRecord;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CashSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$pemasukan = CashCategory::firstOrCreate(['name' => 'pemasukan']);
|
||||
$pengeluaran = CashCategory::firstOrCreate(['name' => 'pengeluaran']);
|
||||
|
||||
$bendahara = User::role('bendahara')->first();
|
||||
$ketua = User::role('ketua')->first();
|
||||
|
||||
$records = [
|
||||
['category_id' => $pemasukan->id, 'amount' => 500000, 'description' => 'Iuran anggota bulan Januari', 'date' => now()->subMonths(2)],
|
||||
['category_id' => $pemasukan->id, 'amount' => 500000, 'description' => 'Iuran anggota bulan Februari', 'date' => now()->subMonth()],
|
||||
['category_id' => $pemasukan->id, 'amount' => 1000000, 'description' => 'Donasi kegiatan kerja bakti', 'date' => now()->subDays(20)],
|
||||
['category_id' => $pengeluaran->id, 'amount' => 250000, 'description' => 'Pembelian alat kebersihan', 'date' => now()->subDays(18)],
|
||||
['category_id' => $pengeluaran->id, 'amount' => 150000, 'description' => 'Konsumsi rapat bulanan', 'date' => now()->subDays(5)],
|
||||
];
|
||||
|
||||
foreach ($records as $data) {
|
||||
CashRecord::create(array_merge($data, [
|
||||
'created_by' => $bendahara?->id,
|
||||
'verified_by' => $ketua?->id,
|
||||
'verified_at' => now()->subDays(1),
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,10 @@ class DatabaseSeeder extends Seeder
|
||||
{
|
||||
$this->call([
|
||||
RolesAndPermissionsSeeder::class,
|
||||
DivisionSeeder::class,
|
||||
UserSeeder::class,
|
||||
ActivitySeeder::class,
|
||||
CashSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Division;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DivisionSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$divisions = [
|
||||
['name' => 'Humas', 'description' => 'Hubungan masyarakat dan komunikasi'],
|
||||
['name' => 'Pendidikan', 'description' => 'Bidang pendidikan dan pelatihan'],
|
||||
['name' => 'Olahraga', 'description' => 'Bidang olahraga dan kesehatan'],
|
||||
['name' => 'Seni & Budaya', 'description' => 'Bidang seni dan pelestarian budaya'],
|
||||
['name' => 'Lingkungan', 'description' => 'Bidang lingkungan hidup'],
|
||||
];
|
||||
|
||||
foreach ($divisions as $division) {
|
||||
Division::firstOrCreate(['name' => $division['name']], $division);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Division;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$divisions = Division::pluck('id', 'name');
|
||||
|
||||
$users = [
|
||||
['name' => 'Budi Santoso', 'email' => 'ketua@persegi.id', 'role' => 'ketua', 'division' => 'Humas'],
|
||||
['name' => 'Siti Rahayu', 'email' => 'bendahara@persegi.id','role' => 'bendahara', 'division' => 'Pendidikan'],
|
||||
['name' => 'Ahmad Fauzi', 'email' => 'pengurus@persegi.id', 'role' => 'pengurus', 'division' => 'Olahraga'],
|
||||
['name' => 'Dewi Lestari', 'email' => 'auditor@persegi.id', 'role' => 'auditor', 'division' => 'Seni & Budaya'],
|
||||
['name' => 'Rizky Pratama', 'email' => 'anggota1@persegi.id', 'role' => 'anggota', 'division' => 'Lingkungan'],
|
||||
['name' => 'Nur Hidayah', 'email' => 'anggota2@persegi.id', 'role' => 'anggota', 'division' => 'Humas'],
|
||||
];
|
||||
|
||||
foreach ($users as $data) {
|
||||
$user = User::firstOrCreate(
|
||||
['email' => $data['email']],
|
||||
[
|
||||
'name' => $data['name'],
|
||||
'password' => bcrypt('password'),
|
||||
'phone' => '08' . rand(100000000, 999999999),
|
||||
'address' => 'Desa Karangdadap, Kalibagor, Banyumas',
|
||||
'division_id' => $divisions[$data['division']] ?? null,
|
||||
'status' => 'aktif',
|
||||
]
|
||||
);
|
||||
|
||||
$user->syncRoles([$data['role']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user