public function myCommunities() { $user_id = \Auth::user()->id; $user = Models\User::find($user_id); $polls = Models\PollsDemand::where('type', '=', 1)->get(); $demands = Models\PollsDemand::where('type', '=', 2)->get(); return view('home', compact('user', 'polls', 'demands')); }
public function loadPollOptions($poll_id) { $poll = PollsDemand::with('details')->with(['votes' => function ($q) use($poll_id) { $q->where('user_id', \Auth::user()->id); $q->where('polls_demand_id', $poll_id); }])->findOrFail($poll_id); return response()->json(['success' => true, 'data' => $poll]); }