| | |
| | | parent::__construct(); |
| | | |
| | | // Set up cache connections |
| | | $this->cache->connect('post')->connect('user')->connect('taxonomy'); |
| | | $this->listsCache = Cache::for('lists')->connect('favourites', true); |
| | | $this->sharedListsCache = Cache::for('sharedLists')->connect('favourites', true); |
| | | $this->favouritesCache = Cache::for('allFavourites')->connect('favourites', true); |
| | | $this->cache->connect('post')->connect('user')->connect('taxonomy')->user(); |
| | | $this->listsCache = Cache::for('lists')->connect('favourites', true)->user(); |
| | | $this->sharedListsCache = Cache::for('sharedLists')->connect('favourites', true)->user(); |
| | | $this->favouritesCache = Cache::for('allFavourites')->connect('favourites', true)->user(); |
| | | |
| | | $this->valid_types = array_merge(Registrar::getRegistered('post'), Registrar::getRegistered('term')); |
| | | |
| | |
| | | 'target_id' => $target_id |
| | | ]); |
| | | |
| | | if ($result['created']) { |
| | | if ((bool)$result) { |
| | | $this->updateFavouriteCount($type, $target_id); |
| | | $this->maybeNotifyOwner($type, $target_id, $user_id); |
| | | } |
| | |
| | | 'type' => $type, |
| | | 'target_id' => $target_id |
| | | ]); |
| | | if ($result['created']) $results['added']++; |
| | | if ((bool) $result) $results['added']++; |
| | | } else { |
| | | $deleted = $table->where([ |
| | | $deleted = $table->delete([ |
| | | 'user_id' => $user_id, |
| | | 'type' => $type, |
| | | 'target_id' => $target_id |
| | | ])->deleteResults(); |
| | | ]); |
| | | if ($deleted) $results['removed']++; |
| | | } |
| | | |