public function getIndex() { $user = Auth::user(); if (empty($user->announcement_expires) || $user->announcement_expires->isPast()) { return Redirect::to('/user/addmoney'); } return View::make('announcements.user.announcements')->with('stream', AnnouncementSeries::find($user->announcement_stream))->with('user', $user)->with('accountSum', Session::get('announcemntsSum', 1000)); }
public function output() { $data = []; $users = User::where('role', '=', 2)->where('show_continent', '=', 1)->orderByRaw("RAND()")->get(); foreach ($users as $user) { if (empty($user->userInfo->country)) { continue; } $continent = $this->continentStringByCountry($user->userInfo->country); $userInfo = array('first_name' => $user->userInfo->first_name, 'last_name' => $user->userInfo->last_name, 'city' => $user->userInfo->city, 'country' => $user->userInfo->country, 'coord' => $user->userInfo->lat . ',' . $user->userInfo->long, 'photo' => $user->userInfo->photo, 'totalInvested' => $user->userMoney->ammount_invested, 'totalReward' => $user->userMoney->ammount_won, 'registered' => $user->created_at, 'point' => $user->show_dot, 'online' => rand(0, 1) == 1, 'continent' => $continent); // Social links. $userInfo['social'] = array(); $sites = array('facebook', 'twitter', 'pinterest', 'odnoklassniki', 'vkontacte'); $links = json_decode($user->userInfo->links, true); if (empty($links)) { $links = array(); } $links = array_pad($links, 5, null); // Build social links hash table. for ($l = 0; $l < count($links); $l++) { if (!empty($links[$l])) { $userInfo['social'][$sites[$l]] = $links[$l]; } } // Pass null if all links are empty. if (count($userInfo['social']) == 0) { $userInfo['social'] = null; } $data[] = $userInfo; } $data = json_encode($data); $totalInfo = ['users_total' => User::where('role', '=', 2)->where('registration_status', '=', 1)->count(), 'users_invested' => User::where('role', '=', 2)->where('investor', '=', 1)->count(), 'users_withdrew' => User::where('role', '=', 2)->where('awarded', '=', 1)->count(), 'total_invested' => DB::table('user_money_info')->sum('ammount_invested'), 'total_won' => DB::table('user_money_info')->sum('ammount_won'), 'total_withdrew' => DB::table('user_money_info')->sum('ammount_withdrawn')]; // Load announcements. $stream = AnnouncementSeries::whereName('xx1')->firstOrFail(); $grouped = $stream->groupedByDate('d.m.Y'); // Show last 5 days starting from yesterday. $grouped['data'] = array_slice($grouped['data'], 1, 5); return View::make('homepage')->with('mapData', $data)->with('totalInfo', $totalInfo)->with('stream', $grouped); }
// Do not show the ticker. $show = false; } $view->with('show', $show)->with('ajax', $ajax)->with('message', $message); }); View::creator('announcements.user.remaining', function ($view) { $left = null; /* @var $user User */ $user = Auth::user(); if ($user && $user->announcement_expires) { if ($user->announcement_expires->isFuture()) { $now = new Carbon\Carbon(); $left = $user->announcement_expires->diff($now); } } $view->with('left', $left); }); View::creator('announcements.user.notifications', function ($view) { // Stream paused until. $paused = null; /* @var $user User */ $user = Auth::user(); if ($user && $user->announcement_expires && $user->announcement_expires->isFuture()) { /* @var $stream AnnouncementSeries */ $stream = AnnouncementSeries::find($user->announcement_stream); if ($stream->paused_until && $stream->paused_until->isFuture()) { $paused = $stream->paused_until->getTimestamp(); } } $view->with('paused', $paused); });
public function postPause($stream) { $time = Input::get('time'); $date = new Carbon($time); $series = AnnouncementSeries::find($stream); $series->paused_until = $date; $series->save(); $this->broadcast(array('stream' => $series, 'type' => 'pause', 'date' => $date->getTimestamp())); }
public function editUserInfoAdmin($uid) { $user = User::find($uid); $user_info = UserInfo::find($user->user_info_id); if ($user_info->birth_date == null) { $birth_date = null; } else { $birth_date = explode("-", $user_info->birth_date); } $disabled = 'disabled'; $links = json_decode($user_info->links); if (empty($links)) { $links = array(); } $links = array_pad($links, 5, null); $streams = AnnouncementSeries::all(); $announcementsStreams = array(0 => 'Отключены'); foreach ($streams as $s) { $announcementsStreams[$s->id] = $s->name; } return View::make('backend.user.userinfo', ['user' => $user, 'user_info' => $user_info, 'birth_date' => $birth_date, 'links' => $links, 'disabled' => $disabled, 'announcements_streams' => $announcementsStreams]); }