<?php

namespace Database\Factories;

use App\Models\Department;
use App\Models\Folder;
use Carbon\Carbon;
use Faker\Provider\DateTime;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Storage;

class FolderFactory extends Factory
{
    /**
     * The name of the factory's corresponding model.
     *
     * @var string
     */
    protected $model = Folder::class;

    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        $inputArray = [5, 15, 25, 35, 45, 55, 65, 75];
        $deptId = Arr::random($inputArray);

        //$deptId = $this->faker->numberBetween(1, 10);

        $deptCode = Department::find($deptId)->code;

        $name = $this->faker->unique()->firstName();

        $location = 'Departments' . DIRECTORY_SEPARATOR . $deptCode . DIRECTORY_SEPARATOR . $name;
        Storage::disk('uploads')->makeDirectory($location);

        return [
            'arch_id' => $deptCode . "/" . $this->faker->unique()->randomNumber(),
            'name' => $name,
            'note' => "This a note field",
            'location' => $location,
            'user_id' => 1,
            'department_id' => $deptId,
            'is_important' => $this->faker->boolean,
            'created_at' => now()
        ];
    }
}
