save(); return $model; } // public function sync_attr($ids, $detaching = true) // { // $changes = [ // 'attached' => [], 'detached' => [], 'updated' => [], // ]; // $current = $this->getCurrentlyAttachedPivots() // ->pluck($this->relatedPivotKey)->all(); // $detach = array_diff($current, array_keys( // $records = $this->formatRecordsList($this->parseIds($ids)) // )); // if ($detaching && count($detach) > 0) { // $this->detach($detach); // // $changes['detached'] = $this->castKeys($detach); // } // $changes = array_merge( // $changes, $this->attachNew($records, $current, false) // ); // if (count($changes['attached']) || // count($changes['updated'])) { // $this->touchIfTouching(); // } // return $changes; // } }