states)->last()); if (static::$user_id and $func->getStaticVariables()['state']['user_id'] != static::$user_id) { static::$currentDate = null; } if (!static::$currentDate) { static::$user_id = $func->getStaticVariables()['state']['user_id']; static::$currentDate = $func->getStaticVariables()['state']['start']; } else { static::$currentDate = static::$currentDate->endOfWeek()->addDay(); } $wBlock = WeekPlanning::getWeekBlock(static::$currentDate); foreach ($wBlock as &$dayRows) { foreach ($dayRows as &$cell) { $cell['type'] = collect(CellType::toArray())->random()->value; if (rand(0, 3)) { $cellModel = collect(CellModel::toArray())->random(); $cell['cellModel'] = $cellModel->value; switch ($cellModel) { case (new Ticket())->getTable(): $cell['foreign'] = Ticket::select(['id']) ->inRandomOrder()->first()->id; break; case (new Site())->getTable(): $cell['foreign'] = Site::select(['id']) ->inRandomOrder()->first()->id; break; case (new Project())->getTable(): $cell['foreign'] = Project::select(['id']) ->inRandomOrder()->first()->id; break; } $cell['text'] = $this->faker->text(rand(20, 50)); } } } return [ 'start' => static::$currentDate, 'planning' => $wBlock ]; } }