source: database/factories/FolderFactory.php@ 8c71900

develop
Last change on this file since 8c71900 was 0208bbd, checked in by Berat Kjufliju <kufliju@…>, 3 years ago

edited pagination

  • Property mode set to 100644
File size: 1.2 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;
10use Illuminate\Support\Facades\Storage;
11
[c6b84df]12class FolderFactory extends Factory
[e6c1f87]13{
14 /**
15 * The name of the factory's corresponding model.
16 *
17 * @var string
18 */
[c6b84df]19 protected $model = Folder::class;
[e6c1f87]20
21 /**
22 * Define the model's default state.
23 *
24 * @return array
25 */
26 public function definition()
27 {
28
[0208bbd]29 $deptId = 1;
[4b7e2d3]30
[c6b84df]31 $deptCode = Department::find($deptId)->code;
[b9c4a92]32 $name = $this->faker->unique()->firstName();
[c6b84df]33
34 $location = 'Departments' . DIRECTORY_SEPARATOR . $deptCode . DIRECTORY_SEPARATOR . $name;
35 Storage::disk('uploads')->makeDirectory($location);
36
[e6c1f87]37 return [
[c6b84df]38 'arch_id' => $deptCode . "/" . $this->faker->unique()->randomNumber(),
[b9c4a92]39 'name' => $name,
[4b7e2d3]40 'note' => "This a note field",
[c6b84df]41 'location' => $location,
[e6c1f87]42 'user_id' => $this->faker->numberBetween('1', '2'),
[c6b84df]43 'department_id' => $deptId,
[e6c1f87]44 'is_important' => $this->faker->boolean,
[b375b43]45 'created_at' => now()
[e6c1f87]46 ];
47 }
48}
Note: See TracBrowser for help on using the repository browser.