Inheritance: extends Illuminate\Database\Eloquent\Model
Beispiel #1
2
 function changeVote()
 {
     $user_id = Auth::user()->id;
     $content_id = Input::get('content_id');
     $content = Input::get('content');
     $vote = Input::get('vote');
     if (!($vote == 1 || $vote == -1)) {
         return back();
     } else {
         $voteObject = Vote::where('user_id', $user_id)->where('content_id', $content_id)->where('content', $content)->first();
         if ($voteObject) {
             $results[] = ['message' => "Daha önce oy verilmiş!", 'vote' => $voteObject->vote, 'div_id' => 'vote_' . $content . '_' . $content_id];
             return Response::json($results);
         } else {
             $votes = Vote::where('content_id', $content_id)->where('content', $content)->get(['vote']);
             if ($votes) {
                 $oldVote = 0;
                 foreach ($votes as $vote_t) {
                     $oldVote += $vote_t['vote'];
                 }
             } else {
                 $oldVote = 0;
             }
             $newVote = new Vote();
             $newVote->user_id = $user_id;
             $newVote->content_id = $content_id;
             $newVote->content = $content;
             $newVote->vote = $oldVote + $vote;
             $newVote->save();
             $results[] = ['message' => 0, 'vote' => $newVote->vote, 'div_id' => 'vote_' . $content . '_' . $content_id];
             return Response::json($results);
         }
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $vote = new Vote();
     $vote->ip = "192.168.56.100";
     $vote->competitors()->associate(1);
     // $vote->users()->associate(1);
     $vote->save();
 }
 public function first($id)
 {
     $user = DB::table('votes')->where('user_id', '=', Auth::user()->id)->where('artikel_id', '=', $id)->first();
     if (is_null($user)) {
         $vote = new Vote();
         $vote->artikel_id = $id;
         $vote->user_id = Auth::user()->id;
         $vote->save();
     }
 }
 public function showByUser($user_id)
 {
     //directly copied pasted from list controller.
     $list = Vote::where('user_id', '=', $user_id)->get();
     $user_list = [];
     foreach ($list as $pro) {
         $product_id = $pro->product_id;
         $product = Product::find($product_id);
         if ($product != null) {
             $created_by = $product['created_by'];
             $category = Category::find($product['category_id']);
             $category = $category['category'];
             $user = User::find($created_by);
             array_add($product, 'category', $category);
             array_add($product, 'created_by_name', $user['name']);
             $initial = explode(".", $product['image_url']);
             $thumbFirst = "";
             for ($i = 0; $i < sizeof($initial) - 1; $i++) {
                 $thumbFirst = $thumbFirst . $initial[$i];
             }
             $thumbnail = $thumbFirst . '-200x200.' . $initial[sizeof($initial) - 1];
             array_add($product, 'thumbnail', $thumbnail);
             array_push($user_list, $product);
         }
     }
     return $user_list;
     //        return response()->json([
     //                'upvotted'=>$user_list]
     //        );
 }
Beispiel #5
0
 public function destroy(Post $post)
 {
     $vote = Vote::where(['post_id' => $post->id, 'user_id' => Auth::user()->id])->first();
     $vote->delete();
     $post->decrement('vote_count');
     return response([]);
 }
 /**
  * Store a newly created resource in storage. Requires a post with 'comment_id' and 'position'
  *
  * @return Response
  */
 public function store()
 {
     //Check user permissions
     if (!Auth::user()->can('create-comment_votes')) {
         abort(401, 'You do not have permission to vote on a comment');
     }
     //Check validation
     $input = Request::all();
     if (!isset($input['comment_id'])) {
         abort(422, 'comment_id is required');
     }
     //Gets the comment that is to be voted on
     $comment = Comment::find($input['comment_id']);
     //Does the fields specified as fillable in the model
     if (!$comment) {
         abort(403, 'There is no comment with the id of ' . $input['comment_id']);
     }
     //Check logged in user has voted, and on this comment's motion
     $vote = Vote::where('user_id', Auth::user()->id)->where('motion_id', $comment->motion_id)->first();
     if (!$vote) {
         abort(403, 'User must vote before posting comment');
     }
     $commentVote = new CommentVote($input);
     $commentVote->comment_id = $comment->id;
     $commentVote->vote_id = $vote->id;
     if (!$commentVote->save()) {
         abort(403, $commentVote->errors);
     }
     return $commentVote;
 }
Beispiel #7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $json = File::get(storage_path() . '/jsondata/votes.json');
     $data = json_decode($json);
     foreach ($data as $obj) {
         Vote::create(array('id' => $obj->id, 'carId' => $obj->carId, 'votes' => $obj->votes, 'points' => $obj->points));
     }
 }
 public function getApproveVote($voteId)
 {
     $vote = Vote::find($voteId);
     $vote->checked = 1;
     $vote->isActive = 1;
     $vote->save();
     return redirect('admin/votes');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store($aid, $vote1)
 {
     $id = Auth::id();
     $vote2 = Vote::all();
     foreach ($vote2 as $v) {
         if ($v->aid == $aid && $v->id == $id) {
             $voter = Vote::find($v->id);
             $voter->delete();
         }
     }
     $vote = new Vote();
     $vote->aid = $aid;
     $vote->id = $id;
     $vote->value = $vote1;
     $vote->save();
     return redirect()->back();
 }
Beispiel #10
0
 /**
  *  Get votes for all skills
  */
 public static function hasVote($voter_id, $skill_id, $player1, $player2)
 {
     $vote = Vote::where('voter_id', '=', $voter_id)->where('skill_id', '=', $skill_id)->where('for_id', '=', $player1)->where('against_id', '=', $player2)->count();
     if ($vote > 0) {
         return "true";
     } else {
         return "false";
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     DB::table('votes')->delete();
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     for ($i = 0; $i < 10000; $i++) {
         Vote::create(['candidate_id' => rand(78, 82)]);
     }
 }
 public function store($topicId, Request $request)
 {
     $data = ['user_id' => Auth::user()->id, 'topic_id' => $topicId];
     if (Vote::where($data)->count() > 0) {
         return response('', 204);
     }
     Vote::create($data);
     return response('', 200);
 }
 public function displayTab($nameTitle)
 {
     $name = Song_data::where('song', $nameTitle)->get();
     $id = Song_data::where('song', $nameTitle)->pluck('id');
     $voteCount = Vote::where('votable_id', $id)->where('votable_type', 'App\\Song_data')->sum('vote');
     $title1 = $nameTitle;
     $title = 'Tab';
     return view('viewTab')->with('LastTenTabs', $name)->with('title1', $title1)->with('title', $title)->with('voteCount', $voteCount);
 }
Beispiel #14
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($user)
 {
     $limit = Request::get('limit') ?: 100;
     if (Auth::user()->id != $user->id && !$user->public && !Auth::user()->can('show-votes')) {
         //Not the current user, or public and not an admin
         abort(401, "You do not have permission to view this non-public user's votes");
     }
     $votes = Vote::where('user_id', $user->id)->active()->with('motion')->paginate($limit);
     return $votes;
 }
Beispiel #15
0
 public function vote($subName, $slug, $value)
 {
     if (!in_array($value, [-1, 0, 1])) {
         abort(400);
     }
     $sub = Sub::where('name', $subName)->firstOrFail();
     $post = Post::where('slug', $slug)->where('sub_id', $sub->id)->firstOrFail();
     try {
         $vote = $post->votes()->where('user_id', auth()->id())->firstOrFail();
     } catch (ModelNotFoundException $e) {
         $vote = new Vote();
     }
     $vote->value = $value;
     $vote->user()->associate(auth()->user());
     $vote->voteable()->associate($post);
     $vote->save();
     $post->score += $value;
     $post->save();
 }
 /**
  * Vote up or down for the given comment.
  *
  * @param \Illuminate\Http\Request $request
  * @param                          $id
  * @return \Illuminate\Http\JsonResponse
  */
 public function vote(Request $request, $id)
 {
     $this->validate($request, ['vote' => 'required|in:up,down']);
     if (Vote::whereCommentId($id)->whereUserId($request->user()->id)->exists()) {
         return response()->json(['errors' => 'Already voted!'], 409);
     }
     $comment = Comment::findOrFail($id);
     $up = $request->input('vote') == 'up' ? true : false;
     $comment->votes()->create(['user_id' => $request->user()->id, 'up' => $up ? 1 : null, 'down' => $up ? null : 1, 'voted_at' => \Carbon\Carbon::now()->toDateTimeString()]);
     return response()->json(['voted' => $request->input('vote'), 'value' => $comment->votes()->sum($request->input('vote'))]);
 }
Beispiel #17
0
 /**
  * Return home page
  *
  * @return \Illuminate\View\View
  */
 public function getHome()
 {
     $lastNews = Category::find(1)->articles->sortBy('created_at')->first();
     $lastEvent = Category::find(2)->articles->sortBy('created_at')->first();
     $lastInterview = Category::find(3)->articles->sortBy('created_at')->first();
     $users = User::all();
     $randUser = $users[rand(0, $users->count() - 1)];
     $votes = Vote::all()->where('status', 'pending');
     $randVote = $votes[rand(0, $votes->count() - 1)];
     return view('front.index', compact('lastNews', 'lastEvent', 'lastInterview', 'randUser', 'randVote'));
 }
Beispiel #18
0
 /**
  * Store a newly created resource in storage.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['vote' => 'required|array|vote_count|vote_unique|sane_votes']);
     $user = $request->user();
     if ($user->uuid === null) {
         $user->update(['uuid' => uuid()]);
     }
     foreach ($request->get('vote') as $vote) {
         Vote::create(['candidate_id' => Candidate::findOrFail($vote)->id, 'user_id' => $user->id, 'term_id' => nextTerm()->id]);
     }
     Session::flash('message', 'Your votes were successfully counted.');
     return redirect('/');
 }
Beispiel #19
0
 public function store(Request $request)
 {
     $this->validate($request, ['postit_id' => 'required', 'value' => "required|integer"], ['required' => 'precisa :attribute', 'integer' => 'precisa ser numero :attribute']);
     $identity = $this->dispatch(new GetIdentity($request));
     $vote = Vote::firstOrNew(['postit_id' => $request->get('postit_id'), 'identifier_id' => $identity->id]);
     if ($vote->value == $request->value) {
         $vote->value = 0;
     } else {
         $vote->value = $request->value;
     }
     $vote->save();
     $vote->postIt->hasVoted = $vote->value;
     return $vote->postIt;
 }
Beispiel #20
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $now = Carbon::now();
     foreach (Vote::all()->where('status', 'pending') as $vote) {
         $date = Carbon::parse($vote->date_end);
         if ($now->timestamp >= $date->timestamp) {
             $vote->status = 'archived';
             $vote->save();
             if ($vote->debates->first()) {
                 Post::create(['user_id' => null, 'debate_id' => $vote->debates->first()->id, 'message' => '<p>Le vote est terminé. <a href="' . url('/forum/vote/' . $vote->id) . '">Les résultats sont consultables dans les archives.</a></p>']);
             }
         }
     }
 }
Beispiel #21
0
 /**
  * A funciton that usually runs recursively up the vote chain
  *
  * @param  VoteCreated  $event
  * @return void
  */
 public function handle($event)
 {
     $vote = $event->vote;
     // \DB::enableQueryLog();
     //DB::enableQueryLogging();
     // \DB::table('votes')->where('deferred_to_id',$vote->user_id)->where('motion_id',$vote->motion_id)->update(['position'=>$vote->position]);
     $deferredVotes = Vote::where('deferred_to_id', $vote->user_id)->where('motion_id', $vote->motion_id)->get();
     //update(['position'=>$vote->position]);
     //  echo print_r(\DB::getQueryLog());
     foreach ($deferredVotes as $deferredVote) {
         // echo "\br HERE ".$deferredVote;
         $deferredVote->position = $vote->position;
         $deferredVote->save();
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('votes')->delete();
     //Voter 1 Julie vs Bernie
     Vote::create(['vote_id' => '1', 'voter_id' => '1', 'skill_id' => '1', 'for_id' => '192412', 'against_id' => '17446']);
     Vote::create(['vote_id' => '2', 'voter_id' => '1', 'skill_id' => '2', 'for_id' => '17446', 'against_id' => '192412']);
     Vote::create(['vote_id' => '3', 'voter_id' => '1', 'skill_id' => '3', 'for_id' => '17446', 'against_id' => '192412']);
     Vote::create(['vote_id' => '4', 'voter_id' => '1', 'skill_id' => '4', 'for_id' => '17446', 'against_id' => '192412']);
     Vote::create(['vote_id' => '5', 'voter_id' => '1', 'skill_id' => '5', 'for_id' => '17446', 'against_id' => '192412']);
     Vote::create(['vote_id' => '6', 'voter_id' => '1', 'skill_id' => '6', 'for_id' => '192412', 'against_id' => '17446']);
     Vote::create(['vote_id' => '7', 'voter_id' => '1', 'skill_id' => '7', 'for_id' => '17446', 'against_id' => '192412']);
     Vote::create(['vote_id' => '8', 'voter_id' => '1', 'skill_id' => '8', 'for_id' => '17446', 'against_id' => '192412']);
     Vote::create(['vote_id' => '9', 'voter_id' => '1', 'skill_id' => '9', 'for_id' => '192412', 'against_id' => '17446']);
     Vote::create(['vote_id' => '10', 'voter_id' => '1', 'skill_id' => '10', 'for_id' => '17446', 'against_id' => '192412']);
     //Voter 2 Julie vs Bernie
     Vote::create(['vote_id' => '11', 'voter_id' => '2', 'skill_id' => '1', 'for_id' => '192412', 'against_id' => '17446']);
     Vote::create(['vote_id' => '12', 'voter_id' => '2', 'skill_id' => '2', 'for_id' => '17446', 'against_id' => '192412']);
     Vote::create(['vote_id' => '13', 'voter_id' => '2', 'skill_id' => '3', 'for_id' => '192412', 'against_id' => '17446']);
     Vote::create(['vote_id' => '14', 'voter_id' => '2', 'skill_id' => '4', 'for_id' => '192412', 'against_id' => '17446']);
     Vote::create(['vote_id' => '15', 'voter_id' => '2', 'skill_id' => '5', 'for_id' => '17446', 'against_id' => '192412']);
     Vote::create(['vote_id' => '16', 'voter_id' => '2', 'skill_id' => '6', 'for_id' => '192412', 'against_id' => '17446']);
     Vote::create(['vote_id' => '17', 'voter_id' => '2', 'skill_id' => '7', 'for_id' => '17446', 'against_id' => '192412']);
     Vote::create(['vote_id' => '18', 'voter_id' => '2', 'skill_id' => '8', 'for_id' => '17446', 'against_id' => '192412']);
     Vote::create(['vote_id' => '19', 'voter_id' => '2', 'skill_id' => '9', 'for_id' => '192412', 'against_id' => '17446']);
     Vote::create(['vote_id' => '20', 'voter_id' => '2', 'skill_id' => '10', 'for_id' => '192412', 'against_id' => '17446']);
     //Voter 3 Julie vs Katie
     Vote::create(['vote_id' => '21', 'voter_id' => '3', 'skill_id' => '1', 'for_id' => '192412', 'against_id' => '172634']);
     Vote::create(['vote_id' => '22', 'voter_id' => '3', 'skill_id' => '2', 'for_id' => '172634', 'against_id' => '192412']);
     Vote::create(['vote_id' => '23', 'voter_id' => '3', 'skill_id' => '3', 'for_id' => '192412', 'against_id' => '172634']);
     Vote::create(['vote_id' => '24', 'voter_id' => '3', 'skill_id' => '4', 'for_id' => '192412', 'against_id' => '172634']);
     Vote::create(['vote_id' => '25', 'voter_id' => '3', 'skill_id' => '5', 'for_id' => '172634', 'against_id' => '192412']);
     Vote::create(['vote_id' => '26', 'voter_id' => '3', 'skill_id' => '6', 'for_id' => '192412', 'against_id' => '172634']);
     Vote::create(['vote_id' => '27', 'voter_id' => '3', 'skill_id' => '7', 'for_id' => '172634', 'against_id' => '192412']);
     Vote::create(['vote_id' => '28', 'voter_id' => '3', 'skill_id' => '8', 'for_id' => '192412', 'against_id' => '172634']);
     Vote::create(['vote_id' => '29', 'voter_id' => '3', 'skill_id' => '9', 'for_id' => '192412', 'against_id' => '172634']);
     Vote::create(['vote_id' => '30', 'voter_id' => '3', 'skill_id' => '10', 'for_id' => '192412', 'against_id' => '172634']);
     //Voter 4 Bernie vs Katie
     Vote::create(['vote_id' => '31', 'voter_id' => '4', 'skill_id' => '1', 'for_id' => '17446', 'against_id' => '172634']);
     Vote::create(['vote_id' => '42', 'voter_id' => '4', 'skill_id' => '2', 'for_id' => '17446', 'against_id' => '172634']);
     Vote::create(['vote_id' => '33', 'voter_id' => '4', 'skill_id' => '3', 'for_id' => '17446', 'against_id' => '172634']);
     Vote::create(['vote_id' => '34', 'voter_id' => '4', 'skill_id' => '4', 'for_id' => '17446', 'against_id' => '172634']);
     Vote::create(['vote_id' => '35', 'voter_id' => '4', 'skill_id' => '5', 'for_id' => '17446', 'against_id' => '172634']);
     Vote::create(['vote_id' => '36', 'voter_id' => '4', 'skill_id' => '6', 'for_id' => '172634', 'against_id' => '17446']);
     Vote::create(['vote_id' => '37', 'voter_id' => '4', 'skill_id' => '7', 'for_id' => '17446', 'against_id' => '172634']);
     Vote::create(['vote_id' => '38', 'voter_id' => '3', 'skill_id' => '8', 'for_id' => '17446', 'against_id' => '172634']);
     Vote::create(['vote_id' => '39', 'voter_id' => '4', 'skill_id' => '9', 'for_id' => '17446', 'against_id' => '172634']);
     Vote::create(['vote_id' => '40', 'voter_id' => '4', 'skill_id' => '10', 'for_id' => '17446', 'against_id' => '172634']);
 }
Beispiel #23
0
 /**
  * Handle the event. Wonder if this could all just be a daily email if the "Updated" field has changed
  *
  * @param  MotionUpdated  $event
  * @return void
  */
 public function handle(MotionUpdated $event)
 {
     $motion = $event->motion;
     $changedFields = $motion->getAlteredLockedFields();
     if (!empty($changedFields)) {
         $motionVotes = Vote::whereHas('user', function ($query) {
             $query->whereNull('deleted_at');
         })->where('motion_id', $motion->id)->get();
         foreach ($motionVotes as $motionVote) {
             $data = array('user' => $motionVote->user, 'motion' => $motion);
             Mail::send('emails.motionchanged', $data, function ($m) use($motionVote) {
                 $m->to($motionVote->user->email, $motionVote->user->first_name . ' ' . $motionVote->user->last_name)->subject('A Motion You Voted On Has Changed');
             });
         }
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create('en_GB');
     for ($i = 0; $i < 50; $i++) {
         for ($j = 0; $j < rand(0, 10); $j++) {
             if (rand(0, 1)) {
                 $vote_up = 1;
                 $vote_down = 0;
             } else {
                 $vote_up = 0;
                 $vote_down = 1;
             }
             \App\Vote::create(['user_id' => 1, 'movie_id' => $i, 'vote_up' => $vote_up, 'vote_down' => $vote_down]);
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * NOTE: You are using a FormRequest without any sort of validation.. revise?
  *
  * @param Requests\VoteRequest|Request $request
  * @param $id
  * @return Response
  */
 public function store(Requests\VoteRequest $request)
 {
     $postId = $request->input('postId');
     $userId = $request->user()->id;
     $value = $request->input('value');
     // Check to see if there is an existing vote
     $vote = Vote::wherePostId($postId)->whereUserId($userId)->first();
     if (!$vote) {
         // First time the user is voting
         Vote::create(['post_id' => $postId, 'user_id' => $userId, 'value' => $value]);
     } else {
         $vote->value == $value ? $vote->delete() : $vote->update(['value' => $value]);
     }
     // AJAX JSON RESPONSE
     return response()->json(['status' => 'success', 'msg' => 'Vote has been added.']);
 }
 public function processBallot(Request $request)
 {
     //mark as voted.
     $key = Key::where('key', $request->input('key'))->first();
     $key->voted = true;
     $key->save();
     $selected_candidates = $request->input('candidate');
     if (sizeof($selected_candidates) != 9) {
         $message = "Vote won't be counted. You didn't chose the right number of candidates.";
         return view('form.success')->with('message', $message);
     }
     foreach ($request->input('candidate') as $id) {
         Vote::create(['candidate_id' => $id]);
     }
     $message = "Thanks for voting.";
     return view('form.success')->with('message', $message);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($motion)
 {
     $passiveVotes = Vote::where('motion_id', $motion->id)->cast()->passive()->get()->groupBy('deferred_to_id');
     $votesCount = array();
     $totalVotes = Vote::where('motion_id', $motion->id)->cast()->count();
     foreach ($passiveVotes as $id => $vote) {
         $count = count($vote);
         $votesCount[$vote[0]->position]['passive']['number'] = $count;
         $votesCount[$vote[0]->position]['passive']['percent'] = floor($count / $totalVotes * 100);
     }
     $activeVotes = Vote::where('motion_id', $motion->id)->cast()->active()->get()->groupBy('position');
     foreach ($activeVotes as $id => $vote) {
         $count = count($vote);
         $votesCount[strval($id)]['active']['number'] = $count;
         $votesCount[strval($id)]['active']['percent'] = floor($count / $totalVotes * 100);
     }
     return $votesCount;
 }
 public function postSubmitVote(Request $request)
 {
     return redirect()->action('HomeController@getGameOver');
     if (!Auth::id()) {
         return response()->json(['message' => 'user not found'], 400);
     }
     $profile = Profile::where('id', '=', $request->input('profileId'))->first();
     if (!$profile || $profile->isActive != 1) {
         return response()->json(['message' => 'profile not found'], 400);
     }
     $vote = Vote::where(['user_id' => Auth::id(), 'profile_id' => $request->input('profileId')])->first();
     if (!$vote || $vote->isActive == 1) {
         return response()->json(['message' => 'cannot change vote'], 400);
     }
     $vote->isActive = 1;
     $vote->save();
     return response()->json(['message' => 'validEntry'], 201);
 }
 public function cancel($group_id, $discussion_id, $comment_id)
 {
     $vote = \App\Vote::firstOrNew(['comment_id' => $comment_id, 'user_id' => auth()->user()->id]);
     // if the vote was 1, we can decrement the total in the comment table
     if ($vote->vote == 1) {
         $comment = \App\Comment::findOrFail($comment_id);
         $comment->vote--;
         $comment->save();
     }
     // if the vote was -1, we can increment the total in the comment table
     if ($vote->vote == -1) {
         $comment = \App\Comment::findOrFail($comment_id);
         $comment->vote++;
         $comment->save();
     }
     $vote->vote = 0;
     $vote->save();
     return redirect()->back();
 }
Beispiel #30
0
 /**
  * Store a newly created resource in storage. Requires the vote_id to be submitted
  *
  * @param int vote_id the comment will be attached to
  * @return Response
  */
 public function store()
 {
     if (!Auth::user()->can('create-comments')) {
         abort(401, 'You do not have permission to write a comment');
     }
     $vote = Vote::find(Request::get('vote_id'));
     if (!$vote) {
         abort(403, "There is no vote with the provided ID of (" . Request::get('vote_id') . ")");
     }
     if ($vote->user_id != Auth::user()->id) {
         abort(403, "You can not comment tied to another users vote");
     }
     $comment = Comment::onlyTrashed()->where('vote_id', $vote->id)->where('user_id', Auth::user()->id)->first();
     if ($comment) {
         $comment->forceDelete();
     }
     $comment = new Comment(Request::all());
     $comment->vote_id = $vote->id;
     if (!$comment->save()) {
         abort(403, $comment->errors);
     }
     return $comment;
 }