first commit
This commit is contained in:
28
database/factories/ConsultantFactory.php
Normal file
28
database/factories/ConsultantFactory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Consultant;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ConsultantFactory extends Factory
|
||||
{
|
||||
protected $model = Consultant::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'nama_perunding' => fake()->company().' Sdn Bhd',
|
||||
'no_pendaftaran_syarikat' => fake()->numerify('20########').' ('.fake()->numerify('#######-A').')',
|
||||
'alamat' => fake()->address(),
|
||||
'emel' => fake()->unique()->safeEmail(),
|
||||
'telefon' => fake()->numerify('07-#######'),
|
||||
'aktif' => true,
|
||||
];
|
||||
}
|
||||
|
||||
public function tidakAktif(): static
|
||||
{
|
||||
return $this->state(fn () => ['aktif' => false]);
|
||||
}
|
||||
}
|
||||
25
database/factories/DataCentreFactory.php
Normal file
25
database/factories/DataCentreFactory.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\DataCentre;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class DataCentreFactory extends Factory
|
||||
{
|
||||
protected $model = DataCentre::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'nama_pusat_data' => 'Pusat Data '.fake()->city(),
|
||||
'tajuk_permohonan' => 'Permohonan Lesen '.fake()->words(2, true),
|
||||
'lokasi_pusat_data' => fake()->city(),
|
||||
'alamat' => fake()->address(),
|
||||
'keluasan_tapak' => fake()->randomFloat(2, 1, 20),
|
||||
'it_load' => fake()->randomFloat(2, 5, 100),
|
||||
'status' => 'aktif',
|
||||
'current_consultant_id' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
44
database/factories/ReportingCycleFactory.php
Normal file
44
database/factories/ReportingCycleFactory.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\ReportingCycle;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ReportingCycleFactory extends Factory
|
||||
{
|
||||
protected $model = ReportingCycle::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$renewalYear = fake()->numberBetween(2026, 2035);
|
||||
$reportingYear = $renewalYear - 2;
|
||||
|
||||
return [
|
||||
'renewal_year' => $renewalYear,
|
||||
'reporting_year' => $reportingYear,
|
||||
'period_start' => Carbon::create($reportingYear, 1, 1),
|
||||
'period_end' => Carbon::create($reportingYear, 12, 31),
|
||||
'cut_off_date' => Carbon::create($renewalYear - 1, 12, 1),
|
||||
'licence_period_year' => 1,
|
||||
'status' => 'aktif',
|
||||
];
|
||||
}
|
||||
|
||||
public function renewalYear(int $year): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'renewal_year' => $year,
|
||||
'reporting_year' => $year - 2,
|
||||
'period_start' => Carbon::create($year - 2, 1, 1),
|
||||
'period_end' => Carbon::create($year - 2, 12, 31),
|
||||
'cut_off_date' => Carbon::create($year - 1, 12, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
public function overdue(): static
|
||||
{
|
||||
return $this->state(fn () => ['cut_off_date' => now()->subDays(5)]);
|
||||
}
|
||||
}
|
||||
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