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