mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-12 07:01:06 +03:30
feat: add factory for models
This commit is contained in:
Executable
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Gallery;
|
||||
use App\Models\Uploadable;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Model>
|
||||
*/
|
||||
class UploadableFactory extends Factory
|
||||
{
|
||||
protected $model = Uploadable::class;
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'uploadable_id' => $this->faker->numberBetween(1, 100), // شناسهی تصادفی برای uploadable
|
||||
'uploadable_type' => $this->faker->word, // نوع تصادفی uploadable
|
||||
'gallery_id' => Gallery::factory(), // شناسهی تصادفی برای gallery (در صورتی که گالریها وجود داشته باشند)
|
||||
'image_role' => $this->faker->word, // نقش تصادفی برای تصویر (مثل 'thumbnail' یا 'featured')
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user