develop
Last change
on this file since d7aa044 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:
1.3 KB
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | namespace Database\Factories;
|
---|
4 |
|
---|
5 | use App\Models\Department;
|
---|
6 | use App\Models\Folder;
|
---|
7 | use Carbon\Carbon;
|
---|
8 | use Faker\Provider\DateTime;
|
---|
9 | use Illuminate\Database\Eloquent\Factories\Factory;
|
---|
10 | use Illuminate\Support\Facades\Storage;
|
---|
11 |
|
---|
12 | class FolderFactory extends Factory
|
---|
13 | {
|
---|
14 | /**
|
---|
15 | * The name of the factory's corresponding model.
|
---|
16 | *
|
---|
17 | * @var string
|
---|
18 | */
|
---|
19 | protected $model = Folder::class;
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Define the model's default state.
|
---|
23 | *
|
---|
24 | * @return array
|
---|
25 | */
|
---|
26 | public function definition()
|
---|
27 | {
|
---|
28 |
|
---|
29 | $deptId = $this->faker->numberBetween('1', '15');
|
---|
30 |
|
---|
31 | $deptCode = Department::find($deptId)->code;
|
---|
32 | $name = $this->faker->unique()->firstName();
|
---|
33 |
|
---|
34 | $location = 'Departments' . DIRECTORY_SEPARATOR . $deptCode . DIRECTORY_SEPARATOR . $name;
|
---|
35 | Storage::disk('uploads')->makeDirectory($location);
|
---|
36 |
|
---|
37 | return [
|
---|
38 | 'arch_id' => $deptCode . "/" . $this->faker->unique()->randomNumber(),
|
---|
39 | 'name' => $name,
|
---|
40 | 'note' => "This a note field",
|
---|
41 | 'location' => $location,
|
---|
42 | 'user_id' => $this->faker->numberBetween('1', '2'),
|
---|
43 | 'department_id' => $deptId,
|
---|
44 | 'is_important' => $this->faker->boolean,
|
---|
45 | 'created_at' => $this->faker->dateTime()
|
---|
46 | ];
|
---|
47 | }
|
---|
48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.