develop
Last change
on this file since 112ba6d was 4b7e2d3, checked in by beratkjufliju <kufliju@…>, 3 years ago |
bug fixes, edited export, added fileSeeder for DB testing
|
-
Property mode
set to
100644
|
File size:
918 bytes
|
Rev | Line | |
---|
[4b7e2d3] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | namespace Database\Factories;
|
---|
| 4 |
|
---|
| 5 | use App\Models\File;
|
---|
| 6 | use App\Models\Folder;
|
---|
| 7 | use Illuminate\Database\Eloquent\Factories\Factory;
|
---|
| 8 | use Illuminate\Support\Facades\Storage;
|
---|
| 9 |
|
---|
| 10 | class FileFactory extends Factory
|
---|
| 11 | {
|
---|
| 12 | /**
|
---|
| 13 | * The name of the factory's corresponding model.
|
---|
| 14 | *
|
---|
| 15 | * @var string
|
---|
| 16 | */
|
---|
| 17 | protected $model = File::class;
|
---|
| 18 |
|
---|
| 19 | /**
|
---|
| 20 | * Define the model's default state.
|
---|
| 21 | *
|
---|
| 22 | * @return array
|
---|
| 23 | */
|
---|
| 24 | public function definition()
|
---|
| 25 | {
|
---|
| 26 | $folderId = $this->faker->numberBetween('1', '500');
|
---|
| 27 |
|
---|
| 28 | $folder = Folder::find($folderId);
|
---|
| 29 | $name = $folder->name . ' - ' . $this->faker->unique()->date() . '.png';
|
---|
| 30 |
|
---|
| 31 | $location = $folder->location . DIRECTORY_SEPARATOR . $name;
|
---|
| 32 |
|
---|
| 33 | return [
|
---|
| 34 | "folder_id" => $folderId,
|
---|
| 35 | "name" => $name,
|
---|
| 36 | "location" => $location,
|
---|
| 37 | "created_at" => $this->faker->dateTime()
|
---|
| 38 | ];
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.