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,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user