public function getTodayVotessCountAttribute() { $order = Order::today(); if ($order == null) { return '0'; } return Vote::where('order_id', '=', $order->id)->where('place_id', '=', $this->id)->count(); }
public function order() { $order = Order::today(); $me = Auth::user()->id; if (!($userOrder = UserOrder::where('user_id', '=', $me)->where('order_id', '=', $order->id)->first())) { $userOrder = new UserOrder(); } $userOrder->user_id = $me; $userOrder->desc = Input::get('desc'); $userOrder->order_id = $order->id; $userOrder->save(); return Redirect::to('main'); }
public static function myVote($me) { return Vote::where('user_id', '=', $me->id)->where('order_id', '=', Order::today()->id)->first(); }