Changeset c6b84df for database/factories
- Timestamp:
- 10/21/21 23:45:59 (3 years ago)
- Branches:
- develop, master
- Children:
- 4b7e2d3
- Parents:
- 6b95845
- Location:
- database/factories
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
database/factories/DepartmentFactory.php
r6b95845 rc6b84df 24 24 public function definition() 25 25 { 26 $location = $this->faker->unique()->numberBetween( '1', '9');27 Storage::disk(' local')->makeDirectory('Departments/' . $location);26 $location = $this->faker->unique()->numberBetween(1, 15); 27 Storage::disk('uploads')->makeDirectory('Departments/' . $location); 28 28 return [ 29 29 'name' => "Department" . $this->faker->unique()->firstName(), 30 30 'code' => $location, 31 'location' => Storage::disk('local')->path('') .'Departments' . DIRECTORY_SEPARATOR . $location,31 'location' => 'Departments' . DIRECTORY_SEPARATOR . $location, 32 32 'user_id' => $this->faker->numberBetween('1', '2'), 33 33 'created_at' => Carbon::now() -
database/factories/FolderFactory.php
r6b95845 rc6b84df 4 4 5 5 use App\Models\Department; 6 use App\Models\ Document;6 use App\Models\Folder; 7 7 use Carbon\Carbon; 8 8 use Illuminate\Database\Eloquent\Factories\Factory; 9 9 use Illuminate\Support\Facades\Storage; 10 10 11 class DocumentFactory extends Factory11 class FolderFactory extends Factory 12 12 { 13 13 /** … … 16 16 * @var string 17 17 */ 18 protected $model = Document::class;18 protected $model = Folder::class; 19 19 20 20 /** … … 26 26 { 27 27 28 $deptID = "5"; 28 $deptId = $this->faker->numberBetween('1', '15'); 29 $deptCode = Department::find($deptId)->code; 29 30 $name = $this->faker->unique()->firstName(); 30 Storage::disk('local')->makeDirectory('Departments' . DIRECTORY_SEPARATOR . $deptID . DIRECTORY_SEPARATOR . $name); 31 32 $location = 'Departments' . DIRECTORY_SEPARATOR . $deptCode . DIRECTORY_SEPARATOR . $name; 33 Storage::disk('uploads')->makeDirectory($location); 34 31 35 32 36 return [ 33 'arch_id' => $dept ID. "/" . $this->faker->unique()->randomNumber(),37 'arch_id' => $deptCode . "/" . $this->faker->unique()->randomNumber(), 34 38 'name' => $name, 35 'description' => $this->faker->realText(), 39 'note' => $this->faker->realText(), 40 'location' => $location, 36 41 'user_id' => $this->faker->numberBetween('1', '2'), 37 'department_id' => $deptI D,42 'department_id' => $deptId, 38 43 'is_important' => $this->faker->boolean, 39 44 'created_at' => $this->faker->dateTime() 40 45 ]; 41 42 46 } 43 47 }
Note:
See TracChangeset
for help on using the changeset viewer.