Exemplo n.º 1
0
 public function topSideBar()
 {
     $users = User::limit(12)->get();
     $tmp = [];
     foreach ($users as $user) {
         $tmp[] = ['id' => $user->id, 'name' => $user->name, 'avatar' => \Timthumb::link($user->avatar, 35, 35, 1), 'point' => 100, 'link' => ''];
     }
     $response = ['status' => '1', 'msg' => 'success', 'data' => $tmp];
     return $this->json($response);
 }
Exemplo n.º 2
0
 /**
  * Show the homepage
  * @return \View
  */
 public function getIndex()
 {
     if (Request::isMethod('post')) {
         $addition = [];
         if (\Auth::check()) {
             $addition = ['check_liked' => ['user_id' => \Auth::user()->id]];
         }
         $posts = $this->post->index(10, null, null, null, 'created_at', 'desc', $addition);
         $tmp = [];
         foreach ($posts as $post) {
             $tmp[] = ['id' => $post->id, 'title' => $post->title, 'slug' => $post->slug, 'code' => $post->code, 'url' => $post->getLink(), 'thumbnail' => \Timthumb::link($post->getThumbnail(), 500), 'username' => $post->username, 'user_id' => $post->user_id, 'type' => $post->type, 'name' => $post->name, 'views' => $post->views, 'likes' => $post->likes, 'score' => $post->score, 'comments' => 0, 'created_at_string' => Date::parse($post->created_at)->diffForHumans()];
         }
         $response = ['status' => '1', 'msg' => 'success', 'data' => $tmp];
         return $this->json($response);
     } else {
         return $this->view('gag.frontend.homes.index');
     }
 }