first
This commit is contained in:
44
database/factories/ApplicationFactory.php
Normal file
44
database/factories/ApplicationFactory.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\Position;
|
||||
use App\Models\PusatMengundi;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<Application>
|
||||
*/
|
||||
class ApplicationFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$pusat = PusatMengundi::factory()->create();
|
||||
$position = Position::factory()->create([
|
||||
'is_public_applyable' => true,
|
||||
]);
|
||||
|
||||
return [
|
||||
'election_id' => $pusat->election_id,
|
||||
'pusat_mengundi_id' => $pusat->id,
|
||||
'public_uuid' => (string) Str::uuid(),
|
||||
'source' => 'public',
|
||||
'status' => 'submitted',
|
||||
'name' => fake()->name(),
|
||||
'ic_number' => fake()->unique()->numerify('############'),
|
||||
'phone_number' => fake()->numerify('01########'),
|
||||
'email' => fake()->safeEmail(),
|
||||
'address' => fake()->address(),
|
||||
'requested_position_id' => $position->id,
|
||||
'bank_name' => 'Maybank',
|
||||
'bank_account_number' => fake()->numerify('############'),
|
||||
];
|
||||
}
|
||||
}
|
||||
27
database/factories/BahagianPilihanrayaFactory.php
Normal file
27
database/factories/BahagianPilihanrayaFactory.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\BahagianPilihanraya;
|
||||
use App\Models\Election;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<BahagianPilihanraya>
|
||||
*/
|
||||
class BahagianPilihanrayaFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'election_id' => Election::factory(),
|
||||
'code' => strtoupper(fake()->unique()->bothify('B##')),
|
||||
'name' => 'Bahagian '.fake()->city(),
|
||||
];
|
||||
}
|
||||
}
|
||||
39
database/factories/DaerahMengundiFactory.php
Normal file
39
database/factories/DaerahMengundiFactory.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\BahagianPilihanraya;
|
||||
use App\Models\DaerahMengundi;
|
||||
use App\Models\Election;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<DaerahMengundi>
|
||||
*/
|
||||
class DaerahMengundiFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$bahagian = BahagianPilihanraya::factory()->create();
|
||||
|
||||
return [
|
||||
'election_id' => $bahagian->election_id,
|
||||
'bahagian_pilihanraya_id' => $bahagian->id,
|
||||
'code' => strtoupper(fake()->unique()->bothify('D##')),
|
||||
'name' => 'Daerah Mengundi '.fake()->streetName(),
|
||||
];
|
||||
}
|
||||
|
||||
public function forElection(Election $election): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'election_id' => $election->id,
|
||||
'bahagian_pilihanraya_id' => BahagianPilihanraya::factory()->for($election)->create()->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
25
database/factories/DunFactory.php
Normal file
25
database/factories/DunFactory.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Dun;
|
||||
use App\Models\Election;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Dun>
|
||||
*/
|
||||
class DunFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'election_id' => Election::factory(),
|
||||
'code' => strtoupper(fake()->unique()->bothify('N##')),
|
||||
'name' => fake()->city(),
|
||||
];
|
||||
}
|
||||
}
|
||||
32
database/factories/ElectionFactory.php
Normal file
32
database/factories/ElectionFactory.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Election;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<Election>
|
||||
*/
|
||||
class ElectionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$pollingDate = now()->addWeeks(4)->toDateString();
|
||||
|
||||
return [
|
||||
'public_uuid' => (string) Str::uuid(),
|
||||
'name' => 'Pilihanraya Negeri '.fake()->year(),
|
||||
'code' => strtoupper(fake()->unique()->bothify('PRN-####')),
|
||||
'status' => 'active',
|
||||
'starts_at' => now()->toDateString(),
|
||||
'polling_date' => $pollingDate,
|
||||
];
|
||||
}
|
||||
}
|
||||
32
database/factories/PositionFactory.php
Normal file
32
database/factories/PositionFactory.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Position;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Position>
|
||||
*/
|
||||
class PositionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$code = strtoupper(fake()->unique()->lexify('???'));
|
||||
|
||||
return [
|
||||
'code' => $code,
|
||||
'name' => 'Jawatan '.$code,
|
||||
'scope' => fake()->randomElement(['pusat', 'saluran', 'external']),
|
||||
'is_public_applyable' => false,
|
||||
'is_assignable' => true,
|
||||
'allows_dual_role' => false,
|
||||
'sort_order' => fake()->numberBetween(1, 99),
|
||||
];
|
||||
}
|
||||
}
|
||||
33
database/factories/PusatMengundiFactory.php
Normal file
33
database/factories/PusatMengundiFactory.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Dun;
|
||||
use App\Models\PusatMengundi;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<PusatMengundi>
|
||||
*/
|
||||
class PusatMengundiFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$dun = Dun::factory()->create();
|
||||
|
||||
return [
|
||||
'election_id' => $dun->election_id,
|
||||
'dun_id' => $dun->id,
|
||||
'public_uuid' => (string) Str::uuid(),
|
||||
'code' => strtoupper(fake()->unique()->bothify('PM###')),
|
||||
'name' => 'SK '.fake()->city(),
|
||||
'address' => fake()->address(),
|
||||
'registration_url' => null,
|
||||
'qr_code_path' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
31
database/factories/SaluranMengundiFactory.php
Normal file
31
database/factories/SaluranMengundiFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\PusatMengundi;
|
||||
use App\Models\SaluranMengundi;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<SaluranMengundi>
|
||||
*/
|
||||
class SaluranMengundiFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$pusat = PusatMengundi::factory()->create();
|
||||
|
||||
return [
|
||||
'election_id' => $pusat->election_id,
|
||||
'pusat_mengundi_id' => $pusat->id,
|
||||
'number' => (string) fake()->numberBetween(1, 10),
|
||||
'name' => 'Saluran '.fake()->numberBetween(1, 10),
|
||||
'voter_count' => fake()->numberBetween(250, 750),
|
||||
];
|
||||
}
|
||||
}
|
||||
33
database/factories/StaffAssignmentFactory.php
Normal file
33
database/factories/StaffAssignmentFactory.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Position;
|
||||
use App\Models\PusatMengundi;
|
||||
use App\Models\StaffAssignment;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<StaffAssignment>
|
||||
*/
|
||||
class StaffAssignmentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$pusat = PusatMengundi::factory()->create();
|
||||
|
||||
return [
|
||||
'election_id' => $pusat->election_id,
|
||||
'position_id' => Position::factory(),
|
||||
'pusat_mengundi_id' => $pusat->id,
|
||||
'status' => 'active',
|
||||
'assigned_at' => now(),
|
||||
'source' => 'factory',
|
||||
];
|
||||
}
|
||||
}
|
||||
45
database/factories/UserFactory.php
Normal file
45
database/factories/UserFactory.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user