<div class="row"> <div class="col-xs-12 col-sm-5 col-md-5 col-lg-5 box"> <div class="box-header"> <h2><i class="icon-user"></i> Member Activity</h2> </div> <div class="box-content"> <div class="box-content"> <ul class="dashboard-list-user"> <?php $users = DB::select(DB::raw('SELECT id,email,first_name,last_name,created_at,activated FROM `users` WHERE (`created_at` >= CURDATE() - INTERVAL 7 DAY) ORDER BY `created_at` DESC LIMIT 5')); foreach ($users as $user) { // user email $email = $user->email; // create some gravatarer object $url = Gravatarer::make(['email' => $email, 'size' => 50, 'defaultImage' => 'mm', 'rating' => 'g'])->url(); echo "<li>"; echo "<a href='#'>"; echo "<img class='dashboard-avatar' alt='" . $email . "' src='" . $url . "'></a><strong>Name:</strong><a href='/user/" . $user->id . "/view/'>" . $user->first_name . ' ' . $user->last_name . '</a><br>'; echo "<strong>Since:</strong>" . $user->created_at . '<br>'; echo "<strong>Status:</strong>"; if ($user->activated == 1) { echo '<span class="label label-success">Activated</span>'; } else { echo '<span class="label label-danger">Not Activated</span>'; } echo "</li>"; // get gravatar <img> html code // $html = $gravatar->html(); } ?>
public function index() { $theme = Theme::uses('site')->layout('default'); $theme->setTitle('Home'); Cache::forget('latest_tr_slides'); Cache::forget('tutorials'); Cache::forget('latest_tutorials'); Cache::forget('latest_tutes'); Cache::forget('topstudents'); Cache::forget('topstudentlist'); $tutorialslides = Cache::remember('latest_tr_slides', 1, function () { $tutorials = Cache::remember('tutorials', 1, function () { return DB::select(DB::raw('SELECT tutorialid FROM assessments GROUP BY tutorialid HAVING(COUNT(*)) ORDER BY COUNT(*) DESC LIMIT 5 ;')); }); $out = ''; if ($tutorials == null) { return $out; } foreach ($tutorials as $tutorial_t) { $out .= "<div>"; $tutorial = Tutorials::find($tutorial_t->tutorialid); $string = $tutorial->content; $string = strlen($string) > 753 ? substr($string, 0, 750) . '...' : $string; $string = wordwrap($string, 200, "<br>\n"); $out .= '<h2 class="title">' . $tutorial->name . '</h2>'; $out .= '<label class="label label-success">Subject </label>' . Subject::find($tutorial->subjectid)->subjectname . ' <label class="label label-success">Grade</label> :- ' . Subject::find($tutorial->subjectid)->grade; $out .= " <br> <br>" . $string; $out .= " <br><a class='btn btn-large' href='/tutorial/" . $tutorial->id . "/'>Read More ...</a> <br> <br> <br>"; $out .= '</div>'; } return $out; }); $latest_tutorials = Cache::remember('latest_tutorials', 20, function () { $tutorials = Cache::remember('latest_tutes', 20, function () { return DB::select(DB::raw('SELECT id from tutorials WHERE published= 1 ORDER BY `created_at` DESC LIMIT 5;')); }); $out = ''; if ($tutorials == null) { return $out; } foreach ($tutorials as $tutorial_t) { $tutorial = Tutorials::find($tutorial_t->id); $string = $tutorial->content; $string = preg_replace("/<img[^>]+\\>/i", "", $string); $images = self::getTutorialImages($tutorial->content); if ($images == null) { // continue; } $string = strlen($string) > 753 ? substr($string, 0, 750) . '...' : $string; $string = wordwrap($string, 200, "<br>\n"); $out .= "<div>"; $out .= '<h2 class="title">' . $tutorial->name . '</h2>'; $out .= '<p style="display:inline-block;"> <label class="label label-success">Subject </label>' . Subject::find($tutorial->subjectid)->subjectname . ' <label class="label label-success">Grade</label> :- ' . Subject::find($tutorial->subjectid)->grade . '</p>'; $out .= " <br> <br>" . $string; $out .= "<img src='" . $images[rand(0, count($images) - 1)] . "' class='' style='height:100%;'/>"; $out .= " <br><a class='btn btn-large' href='/tutorial/" . $tutorial->id . "/'>Read More ...</a> <br> <br> <br>"; $out .= '</div>'; } return $out; }); $topstudents = Cache::remember('topstudents', 20, function () { $out = ''; $topstudentlist = Cache::remember('topstudentlist', 20, function () { return DB::select(DB::raw('SELECT studentid as sid,AVG(marks) as average FROM assessments WHERE `created_at` >= CURDATE() - INTERVAL 7 DAY GROUP BY studentid ORDER BY average DESC LIMIT 0,5;')); }); if ($topstudentlist == null) { return $out; } foreach ($topstudentlist as $student) { $user = User::find($student->sid); $url = Gravatarer::make(['email' => $user->email, 'size' => 200, 'defaultImage' => 'mm', 'rating' => 'g'])->url(); $out .= "<div>"; $out .= "<img style='clear:left;' class='avatar' alt='" . $user->email . "' src='" . $url . "'/>\n\t\t<br><strong>Name:</strong>" . $user->first_name . ' ' . $user->last_name . ''; $out .= "<br><label class='label label-success'>Average Score</label> is " . (int) $student->average . ""; $out .= "</div>"; } return $out; }); $add = ['tutorialslides' => $tutorialslides, 'latesttutorialslides' => $latest_tutorials, 'topstudents' => $topstudents]; return $theme->scope('index', $add)->content(); }