source: database/factories/FolderFactory.php@ 68694d4

develop
Last change on this file since 68694d4 was df6e9ec, checked in by beratkjufliju <kufliju@…>, 3 years ago

edited folder seeder

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