Init: Hoan thanh kien truc V3 va Filament UI
This commit is contained in:
29
database/factories/ContractFactory.php
Normal file
29
database/factories/ContractFactory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Contract;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ContractFactory extends Factory
|
||||
{
|
||||
protected $model = Contract::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'product_id' => Product::factory(),
|
||||
'contract_number' => 'HDMB-' . $this->faker->unique()->numberBetween(10000, 99999),
|
||||
'contract_type' => 'HĐMB',
|
||||
'signing_date' => $this->faker->date(),
|
||||
'status' => 'Đang hiệu lực',
|
||||
'total_value' => fn (array $attributes) => Product::find($attributes['product_id'])->total_price,
|
||||
'paid_amount' => function (array $attributes) {
|
||||
$total = Product::find($attributes['product_id'])->total_price;
|
||||
return $this->faker->randomFloat(2, 0, $total);
|
||||
},
|
||||
'transfer_order' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
28
database/factories/CustomerFactory.php
Normal file
28
database/factories/CustomerFactory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class CustomerFactory extends Factory
|
||||
{
|
||||
protected $model = Customer::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'full_name' => $this->faker->name(),
|
||||
'cmnd_cccd' => $this->faker->unique()->numerify('0##########'),
|
||||
'phone' => $this->faker->phoneNumber(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'address' => [
|
||||
'street' => $this->faker->streetAddress(),
|
||||
'ward' => 'Phường ' . $this->faker->numberBetween(1, 15),
|
||||
'district' => 'Quận ' . $this->faker->numberBetween(1, 12),
|
||||
'city' => $this->faker->city(),
|
||||
],
|
||||
'dob' => $this->faker->date(),
|
||||
];
|
||||
}
|
||||
}
|
||||
43
database/factories/ProductFactory.php
Normal file
43
database/factories/ProductFactory.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ProductFactory extends Factory
|
||||
{
|
||||
protected $model = Product::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
$type = $this->faker->randomElement(['LAND', 'APARTMENT']);
|
||||
$area = $this->faker->randomFloat(2, 50, 200);
|
||||
$pricePerUnit = $this->faker->numberBetween(20, 100) * 1000000; // 20M to 100M VND
|
||||
|
||||
$customData = match ($type) {
|
||||
'LAND' => [
|
||||
'frontage' => $this->faker->numberBetween(1, 3),
|
||||
'road_width' => $this->faker->numberBetween(6, 30),
|
||||
],
|
||||
'APARTMENT' => [
|
||||
'block' => $this->faker->randomElement(['A', 'B', 'C']),
|
||||
'floor' => $this->faker->numberBetween(2, 30),
|
||||
'view' => $this->faker->randomElement(['Hồ bơi', 'Công viên', 'Thành phố']),
|
||||
],
|
||||
};
|
||||
|
||||
return [
|
||||
'project_id' => Project::factory(),
|
||||
'product_type' => $type,
|
||||
'code' => 'STH-' . $this->faker->unique()->numberBetween(1000, 9999),
|
||||
'area' => $area,
|
||||
'price_per_unit' => $pricePerUnit,
|
||||
'total_price' => $area * $pricePerUnit,
|
||||
'custom_data' => $customData,
|
||||
'status' => 'Đang mở bán',
|
||||
'red_book_status' => 'Chưa có dữ liệu',
|
||||
];
|
||||
}
|
||||
}
|
||||
20
database/factories/ProjectFactory.php
Normal file
20
database/factories/ProjectFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Project;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ProjectFactory extends Factory
|
||||
{
|
||||
protected $model = Project::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'Khu đô thị HQLand ' . $this->faker->unique()->city(),
|
||||
'type' => $this->faker->randomElement(['Khu đô thị', 'Chung cư', 'Đất nền phân lô']),
|
||||
'address' => $this->faker->address(),
|
||||
];
|
||||
}
|
||||
}
|
||||
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