source: database/factories/FolderFactory.php@ e0d3f94

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

edited FolderFactory

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[e6c1f87]1<?php
2
3namespace Database\Factories;
4
5use App\Models\Department;
[c6b84df]6use App\Models\Folder;
[e6c1f87]7use Carbon\Carbon;
[4b7e2d3]8use Faker\Provider\DateTime;
[e6c1f87]9use Illuminate\Database\Eloquent\Factories\Factory;
[e0d3f94]10use Illuminate\Support\Arr;
[e6c1f87]11use Illuminate\Support\Facades\Storage;
12
[c6b84df]13class 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 {
[e0d3f94]29 $array = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145];
[e6c1f87]30
[e0d3f94]31 $deptId = Arr::random($array);
[4b7e2d3]32
[c6b84df]33 $deptCode = Department::find($deptId)->code;
[b9c4a92]34 $name = $this->faker->unique()->firstName();
[c6b84df]35
36 $location = 'Departments' . DIRECTORY_SEPARATOR . $deptCode . DIRECTORY_SEPARATOR . $name;
37 Storage::disk('uploads')->makeDirectory($location);
38
[e6c1f87]39 return [
[c6b84df]40 'arch_id' => $deptCode . "/" . $this->faker->unique()->randomNumber(),
[b9c4a92]41 'name' => $name,
[4b7e2d3]42 'note' => "This a note field",
[c6b84df]43 'location' => $location,
[e742574]44 'user_id' => 1,
[c6b84df]45 'department_id' => $deptId,
[e6c1f87]46 'is_important' => $this->faker->boolean,
[b375b43]47 'created_at' => now()
[e6c1f87]48 ];
49 }
50}
Note: See TracBrowser for help on using the repository browser.