/** * Creates new vote entry and returns response data. * * @param string $entity * @param integer $targetId * @param integer $value * @return array */ protected function createVote($entity, $targetId, $value) { $vote = new Vote(); $vote->entity = $entity; $vote->target_id = $targetId; $vote->value = $value; if ($vote->save()) { return ['success' => true]; } else { return ['success' => false, 'errors' => $vote->errors]; } }