本文整理汇总了PHP中Vote::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Vote::where方法的具体用法?PHP Vote::where怎么用?PHP Vote::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vote
的用法示例。
在下文中一共展示了Vote::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNote
public function getNote()
{
$user = Request::get('user_id');
$post = Request::get('post_id');
$vote = Vote::where('user_id', $user)->where('post_id', $post)->first();
return $vote->note;
}
示例2: userHasVoted
public function userHasVoted()
{
$vote = Vote::where('user_id', '=', Auth::id())->where('meetup', '=', $this->id)->first();
if ($vote) {
return true;
}
return false;
}
示例3: vote_store
public function vote_store($id)
{
$same = Vote::where('user_id', '=', $id)->where('login_id', '=', Auth::User()->id)->get();
//var_dump($same);die;
if (count($same) != 0 and $same) {
return Redirect::back();
} else {
$votes = new Vote();
$data = Input::all();
$data['login_id'] = Auth::User()->id;
$data['user_id'] = $id;
$votes->create($data);
return Redirect::intended('home');
}
}
示例4: viewPhotos
public function viewPhotos($id)
{
$album = Album::find($id);
if ($album === null) {
$error = 'Invalid album.';
return View::make('errors.error', array('errorMsg' => $error));
}
if (Auth::user()) {
$isVoted = sizeof(Vote::where('album_id', '=', $album->id)->where('voter_id', '=', Auth::user()->id)->get()) !== 0;
# code...
} else {
$isVoted = true;
}
$comments = Comment::where('album_id', '=', $album->id)->with('author')->get();
return View::make('albums.viewPhotos', array('photos' => $album->photos()->get(), 'comments' => $comments, 'albumId' => $album->id, 'isVoted' => $isVoted));
}
示例5: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$users = User::where('id', '!=', Auth::id())->where('priviledge', '!=', 'superuser')->get();
if (Auth::user()->priviledge != 'superuser') {
$weights = Vote::where('user_id', '=', Auth::id())->sum('performance');
$sum = $weights;
}
//echo "<pre>";
//var_dump($users);die;
foreach ($users as $key => $value) {
$path[$key] = file::where('user_id', '=', $value['id'])->pluck('path');
//echo "<pre>";
//var_dump($path);die;
}
return View::make('votes.home', compact(Auth::user()->user_name, 'users', 'sum', 'path'));
}
示例6: dislikePost
public function dislikePost()
{
$id = Input::get('id');
$dislikeVote = Vote::where('type', 'dislike')->where('user_id', Auth::id())->where('post_id', $id)->first();
if (!$dislikeVote) {
$oppositeVote = Vote::where('type', 'like')->where('user_id', Auth::id())->where('post_id', $id)->first();
if (!empty($oppositeVote)) {
$oppositeVote->delete();
}
$vote = new Vote();
$vote->user_id = Auth::id();
$vote->post_id = $id;
$vote->type = 'dislike';
$vote->save();
}
$totalLikeVote = Vote::where('type', 'like')->where('post_id', $id)->count();
$totalDislikeVote = Vote::where('type', 'dislike')->where('post_id', $id)->count();
$result = array($totalLikeVote, $totalDislikeVote);
return Response::json($result);
}
示例7: voteDownQuestion
public function voteDownQuestion($qid)
{
$dbCheck = Vote::where('user_id', '=', Auth::user()->user_id)->where('question_id', '=', $qid)->first();
if ($dbCheck) {
return Redirect::route('single-question', $qid)->with('global', 'Sorry, you Previously vote this question');
} else {
$vote = new Vote();
$vote->user_id = Auth::user()->user_id;
$vote->question_id = $qid;
$vote->vote = 0;
$vote->save();
/*Insert point to the Vote user*/
$insertPoint = User::find(Auth::user()->user_id);
$insertPoint->points = $insertPoint->points - 1;
$insertPoint->save();
/*Insert point to the Question user*/
$questionuser = Question::where('id', '=', $qid)->first();
$insertPoint = User::find($questionuser->user_id);
$insertPoint->points = $insertPoint->points - 2;
$insertPoint->save();
return Redirect::route('single-question', $qid)->with('global', 'Your Successfully vote down this question');
}
}
示例8: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
if (!Auth::guest()) {
$user = User::where('priviledge', '!=', 'superuser')->get();
$user_designation = Designation::where('id', '=', Auth::user()->id)->pluck('designation');
$user_votes = Vote::where('user_id', '=', Auth::user()->id)->get();
$count = count($user_votes);
$i = 0;
foreach ($user_votes as $user_vote) {
$user_name[$i] = user::where('id', '=', $user_vote->login_id)->pluck('user_name');
$i++;
}
//var_dump($user_name);die;
$weights = Vote::where('user_id', '=', Auth::id())->sum('performance');
$sum = $weights;
$name = priviledge::where('user_id', '=', Auth::user()->id)->pluck('name_show');
$path = file::where('user_id', '=', Auth::user()->id)->pluck('path');
$authority = Priviledge::all();
return View::make('votes.profile', compact('authority', 'path', 'user_designation', 'user_votes', 'sum', 'user', 'name', 'user_name'));
} else {
return Redirect::intended('login');
}
}
示例9: action_vote
public static function action_vote($id = null)
{
if (!$id) {
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
return Response::error(404);
} else {
$id = (int) Param::post('id');
$answers = Param::post('answers');
$poll = Poll::get($id);
$poll->various_answers = '0' != $poll->various_answers;
$cookiename = 'p_' . $poll->id . '_v';
// Si no hay respuestas o hay más de una respuesta
if (count($answers) === 0 || !$poll->various_answers && count($answers) > 1) {
Redirect::to(Url::get('vote', $id, 'vote_error=true'));
}
if (Vote::where('voter_ip', '=', CURRENT_USER_IP)->and_where('poll_id', '=', $id)->first() || Cookie::get($cookiename)) {
Cookie::set($cookiename, !$poll->various_answers ? (string) $answers[0] : 'true', 360);
Redirect::to(Url::get('view', $poll->slug, 'poll_already_voted=true'));
}
Cookie::set($cookiename, !$poll->various_answers ? (string) $answers[0] : 'true', 360);
Vote::create(array('voter_ip' => CURRENT_USER_IP, 'poll_id' => $id, 'answer_id' => !$poll->various_answers ? $answers[0] : 0));
foreach ($answers as $answer_id) {
Answer::find($answer_id)->set(array('nofilter:votes' => '`votes` + 1'));
}
Poll::find($id)->set(array('nofilter:total_votes' => '`total_votes` + 1'));
Redirect::to(Url::get('view', $poll->slug, 'voted=true'));
}
} elseif (!is_numeric($id)) {
return Response::error(404);
}
$id = intval($id, 10);
if (!($poll = Poll::get($id))) {
return Response::error(404);
}
$answers = Answer::where('poll_id', '=', $poll->id)->get();
return View::make('vote')->add_var('poll', $poll)->add_var('answers', $answers);
}
示例10: vote
function vote($obj)
{
$btn1 = 'default';
$disabled1 = '';
$btn2 = 'default';
$disabled2 = '';
$obj_id = '$' . strtolower($obj)->id;
if (Auth::check()) {
$user_id = Auth::user()->id;
$vote = Vote::where('user_id', $user_id)->where('obj_id', $obj_id)->where('obj', $obj)->first();
if ($vote) {
if ($vote->vote == 1) {
$btn1 = 'success';
$disabled2 = 'disabled="disabled"';
} elseif ($vote->vote == -1) {
$btn2 = 'danger';
$disabled1 = 'disabled="disabled"';
}
}
}
?>
<div class="btn-group" id="vote-btn">
<button
class="btn btn-{{ $btn1 }}"
id="voteUp" {{ $disabled1 }}>
<i class="fa fa-thumbs-o-up"></i>
</button>
<button
class="btn btn-{{ $btn2 }}"
id="voteDown" {{ $disabled2 }}>
<i class="fa fa-thumbs-o-down"></i>
</button>
</div>
<?php
}
示例11: doVoting
public function doVoting()
{
if (Auth::guest()) {
echo json_encode(array('status' => 'error', 'message' => Lang::get('texts.request_login')));
exit;
}
$user = Confide::user();
$user_id = $user->id;
$coinvote_id = $_POST['coinvote_id'];
$user_vote = Vote::where('user_id', $user_id)->where('coinvote_id', $coinvote_id)->first();
if (isset($user_vote->user_id)) {
echo json_encode(array('status' => 'error', 'message' => Lang::get('texts.you_voted')));
exit;
} else {
/*$trade = Trade::where('seller_id',$user_id)->orwhere('buyer_id',$user_id)->first();
if(!isset($trade->id)){
echo json_encode(array('status'=>'error','message'=> Lang::get('texts.must_have_trade')));
exit;
}*/
$date = date("Y-m-d");
$times_vote = Vote::where('created_at', '>=', $date)->where('user_id', $user_id)->orderby('created_at', 'desc')->get()->toArray();
$count = count($times_vote);
if ($count > 5) {
echo json_encode(array('status' => 'error', 'message' => Lang::get('texts.over_perday'), 'count' => $count, 'times_vote' => $times_vote));
exit;
} else {
$vote = new Vote();
//Vote::insert();
$vote->coinvote_id = $coinvote_id;
$vote->user_id = $user_id;
$vote->save();
echo json_encode(array('status' => 'success', 'message' => Lang::get('texts.vote_success'), 'count' => $count, 'times_vote' => $times_vote, 'vote_id' => $vote->id));
exit;
}
}
}
示例12: votes
public function votes()
{
return Vote::where('post_id', $this->id);
}
示例13: starSkin
function starSkin($id)
{
$skin = Skin::find($id);
$star = Vote::firstOrNew(array("user_id" => Auth::user()->id, "skin_id" => $id));
$userstar = Vote::where("user_id", Auth::user()->id)->where("skin_id", $id)->first();
if (isset($userstar)) {
$userstar->delete();
$skin->votes -= 1;
} else {
$skin->votes += 1;
$star->save();
}
$skin->save();
return Response::json("success");
}
示例14: vote_null
private function vote_null($id, $obj, $action)
{
if (Auth::check()) {
$user_id = Auth::user()->id;
$vote = Vote::where('user_id', $user_id)->where('obj_id', $id)->where('obj', $obj)->first()->delete();
$obj = $obj::find($id);
if ($action == 'up') {
$obj->vote_up -= 1;
} elseif ($action == 'down') {
$obj->vote_down += 1;
}
$obj->save();
$arr = [];
$arr['vote_up'] = $obj->vote_up;
$arr['vote_down'] = $obj->vote_down;
return $arr;
}
}
示例15: redo
public function redo($id)
{
$accounts = Account::where('vote_id', '=', $id)->get();
$votes = Vote::where('id', '=', $id)->get();
$school_no = $votes[0]->school_no;
$vote_amount = $votes[0]->vote_amount;
$redo = 1;
$data = [$accounts, $school_no, $vote_amount, $redo];
$vote_data = [$id, $vote_amount];
//$redo = 1;
//echo "id",$votes[0]->$id,"amount",$votes[0]->vote_amount;
Session::put('vote_id', $id);
Session::put('vote_data', $vote_data);
Session::put('redo', 1);
}