/** * Save the changes. * * @param Issue $issue * * @return bool */ public function persist(Issue $issue) { $issue->user_id = $issue->exists ? $issue->user_id : Auth::id(); $issue->title = $this->input('title', $issue->title); $issue->description = $this->input('description', $issue->description); $issue->occurred_at = $this->input('occurred_at', $issue->occurred_at); if ($issue->save()) { // Check if we have any files to upload and attach. if (count($this->files) > 0) { foreach ($this->file('files') as $file) { if (!is_null($file)) { $issue->uploadFile($file); } } } // Sync the issues labels. $labels = $this->input('labels', []); if (is_array($labels)) { $issue->labels()->sync($labels); } // Sync the issues users. $users = $this->input('users', []); if (is_array($users)) { $issue->users()->sync($users); } return true; } return false; }
/** * Save the changes. * * @param Issue $issue * * @return bool */ public function persist(Issue $issue) { $issue->users()->sync($this->input('users', [])); return true; }