public function update(Task $task) { $task->fill($this->all()); $task->user_id = $this->getAuthUserId(); $task->finalized_at = $this->get('status') ? new \DateTime() : null; if (!$task->update()) { $this->failedUpdateModel(); } return $task; }
protected function seedTasks(User $user) { $categories = $user->categories()->take(4)->orderByRaw("RAND()")->get(); foreach ($categories as $category) { for ($i = 0; $i < 4; $i++) { $data = ['name' => $this->faker->sentence, 'description' => $this->faker->paragraph(2), 'category_id' => $category->id, 'user_id' => $user->id, 'status' => $this->faker->boolean(80)]; Task::create($data); } } }