Recount likes of model type.

@param string $modelType
@return void

@throws \Cog\Likeable\Exceptions\ModelInvalidException
436824
protected function recountLikesOfModelType($modelType)
    {
        $modelType = $this->normalizeModelType($modelType);

        $counters = $this->service->fetchLikesCounters($modelType, $this->likeType);

        $this->service->removeLikeCountersOfType($modelType, $this->likeType);

        DB::table(app(LikeCounterContract::class)->getTable())->insert($counters);

        $this->info('All [' . $modelType . '] records likes has been recounted.');
    }
359988
public function afterDelete(Model $Model) {
		if ($this->settings[$Model->alias]['auto'] === false) {
			return;
		}
		if (!$Model->ShadowModel) {
			return;
		}
		if (isset($this->deleteUpdates[$Model->alias]) && !empty($this->deleteUpdates[$Model->alias])) {
			foreach ($this->deleteUpdates[$Model->alias] as $assocAlias => $assocIds) {
				$Model->{$assocAlias}->updateRevisions($assocIds);
			}
			unset($this->deleteUpdates[$Model->alias]);
		}
	}
941705
public function unlike($userId=null)
	{
		if(is_null($userId)) {
			$userId = $this->loggedInUserId();
		}
		
		if($userId) {
			$like = $this->likes()
				->where('user_id', '=', $userId)
				->first();
	
			if(!$like) { return; }
	
			$like->delete();
		}

		$this->decrementLikeCount();
	}
833098
protected function dropTableIfExists(string $modelClass): void
    {
        assert(
            $this->getModelSchemas()->hasClass($modelClass),
            "Class `$modelClass` is not found in model Schemas."
        );
        $tableName     = $this->getModelSchemas()->getTable($modelClass);
        $schemaManager = $this->getSchemaManager();

        if ($schemaManager->tablesExist([$tableName]) === true) {
            $schemaManager->dropTable($tableName);
        }
    }
828438
public function scopeWhereLiked($query, Model $model)
    {
        return $query->whereHas('likes', function ($query) use ($model) {
            $query->where('liked_by_id', $model->id);
            $query->where('liked_by_type', get_class($model));
        });
    }
63126
public function like(Model $likedBy): bool
    {
        if ($this->getLikedRecord($likedBy)) {
            return false;
        }

        $like = new Like();
        $like->liked_by_id = $likedBy->id;
        $like->liked_by_type = get_class($likedBy);
        $this->likes()->save($like);

        return (bool) $this->incrementCounter();
    }
24161
protected function setModel()
    {
        if (count($this->models) > 1) {
            $this->info('You need to select which model you want to update');
            foreach ($this->models as $key => $value) {
                $this->info("[$key] $value");
            }
            $askModel = $this->ask('Which model would you like to use?', array_keys($this->models)[0]);

            if (!array_key_exists($askModel, $this->models)) {
                throw new InvalidModelException('The input you gave is not valid');
            }

            $this->model = new $this->models[$askModel];
        } else {
            $this->model = new $this->models[array_keys($this->models)[0]];
        }
    }
1247778
public function setConsentType($consentType)
    {
        if ($consentType !== self::CONSENT_SIMPLE &&
            $consentType !== self::CONSENT_NONE) {
            throw new InvalidArgumentException('Invalid consent type provided.');
        }

        $this->consentType = $consentType;
    }
780036
public function initBySetting($model, $setting)
    {
        parent::initBySetting($model, $setting);
        if (is_array($setting)) {
            if (isset($setting['remote_class_type'])) {
                $this->remoteModelType = $setting['remote_class_type'];
            }
        }
    }
874721
public function containsById($modelId)
    {
        /** @var ModelInterface $localModel */
        foreach ($this as $localModel) {
            if ($modelId === $localModel->getId()) {
                return true;
            }
        }

        return false;
    }
1268144
public function saved($model)
    {
        if (static::syncingDisabledFor($model)) {
            return;
        }

        if (! $model->shouldBeSearchable()) {
            $model->unsearchable();

            return;
        }

        $model->searchable();
    }
1214257
public function setRatingType(string $ratingType): string
    {
        if (static::isValidRatingType($ratingType) === false) {
            throw new InvalidArgumentException('Invalid rating type');
        }
        $previous         = $this->ratingType;
        $this->ratingType = $ratingType;

        return $previous;
    }
1363159
public function likeIt($user = null)
    {
        if (!$this->isLiked()) {
            $this->likes()->create([
                'user_id'=> $user ? $user->id : auth()->id()
            ]);
            $this->incrementCount();
        }
    }
366885
public function removeLikeCountersOfType($likeableType, $type = null)
    {
        if (class_exists($likeableType)) {
            /** @var \Cog\Likeable\Contracts\Likeable $likeable */
            $likeable = new $likeableType;
            $likeableType = $likeable->getMorphClass();
        }

        /** @var \Illuminate\Database\Eloquent\Builder $counters */
        $counters = app(LikeCounterContract::class)->where('likeable_type', $likeableType);
        if (!is_null($type)) {
            $counters->where('type_id', $this->getLikeTypeId($type));
        }
        $counters->delete();
    }
485191
public function dislike(Model $likedBy): bool
    {
        if (!$like = $this->getLikedRecord($likedBy)) {
            return false;
        }

        $like->delete();

        return (bool) $this->decrementCounter();
    }
609094
protected function redirectPreview($type, $model)
    {
        $params = [];
        $params['type'] = $type;
        $params['id'] = $model->id;
        \Staq\Util::httpRedirectUri(\Staq::App()->getUri($this, 'preview', $params));
    }
427383
public function update(Evaluation $evaluation, NodeType $nodeType)
    {
        if ($nodeType == NodeType::MAX()) {
            $this->alpha = max($this->alpha, $evaluation->score);
        } elseif ($nodeType == NodeType::MIN()) {
            $this->beta = min($this->beta, $evaluation->score);
        }
    }