mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-12 15:37:04 +03:30
feat: add factory for models
This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model>
|
||||
*/
|
||||
class PackageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->word,
|
||||
'note' => $this->faker->optional()->word,
|
||||
'user_id' => User::factory(), // ایجاد کاربر به طور خودکار
|
||||
'bar_code' => $this->faker->optional()->word,
|
||||
'qr_code' => $this->faker->optional()->word,
|
||||
'creator_id' => User::factory(), // ایجاد کاربر دیگر به عنوان creator
|
||||
'status' => $this->faker->randomElement(['approved', 'rejected', 'suspended']),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user