*/ class FileFactory extends Factory { protected $model = File::class; public function definition(): array { $filename = fake()->word() . '.' . fake()->randomElement(['jpg', 'png', 'pdf', 'xlsx']); return [ 'user_id' => User::factory(), 'original_name' => $filename, 'mime_type' => fake()->mimeType(), 'path' => 'files/' . fake()->uuid() . '/' . $filename, 'link' => '/storage/files/' . fake()->uuid() . '/' . $filename, ]; } public function image(): static { return $this->state(fn (array $attributes) => [ 'original_name' => fake()->word() . '.jpg', 'mime_type' => 'image/jpeg', ]); } public function pdf(): static { return $this->state(fn (array $attributes) => [ 'original_name' => fake()->word() . '.pdf', 'mime_type' => 'application/pdf', ]); } public function excel(): static { return $this->state(fn (array $attributes) => [ 'original_name' => fake()->word() . '.xlsx', 'mime_type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', ]); } }