public static function getPhoto($id) { $photo = DB::table('photos AS p')->join('users AS u', 'p.user_id', '=', 'u.id')->join('files AS f', 'f.parent_id', '=', 'p.id')->where('p.id', $id)->select(array('*', 'p.id AS photo_id', 'p.creation_date AS photo_creation_date'))->first(); $photo->time_interval = calculate_time_period($photo->photo_creation_date); $photo->photo_view_count = show_view_count($photo->photo_view_count); $photo->view_count = show_view_count($photo->view_count); return $photo; }
public static function getVideo($id) { $video = DB::table('videos AS v')->join('users AS u', 'v.user_id', '=', 'u.id')->where('v.id', $id)->select(array('*', 'v.id AS video_id', 'v.creation_date AS video_creation_date'))->first(); $video->time_interval = calculate_time_period($video->video_creation_date); $video->video_view_count = show_view_count($video->video_view_count); $video->view_count = show_view_count($video->view_count); return $video; }
<?php // View::composers(array( // // 'SideBarComposer' => array('includes.sidebar'), // 'TopUsersComposer' => array('includes.topusers') // )); View::composer('includes.topusers', function ($view) { $topusers = DB::table('users')->orderBy('view_count', 'DESC')->select(array('*'))->take(10)->select(array('id', 'username', 'displayname', 'view_count'))->get(); foreach ($topusers as $key => &$item) { $item->view_count = show_view_count($item->view_count); } $view->with('topusers', $topusers); }); View::composer('includes.photo_sidebar', function ($view) { $photos = DB::table('photos AS p')->join('users AS u', 'p.user_id', '=', 'u.id')->join('files AS f', 'f.parent_id', '=', 'p.id')->select(array('*', 'p.id AS photo_id'))->skip(0)->take(5)->get(); $view->with('photos', $photos); });