/** * Returns all the blog posts. * * @return View */ public function getIndex() { // Get all the blog posts $posts = $this->post->orderBy('created_at', 'DESC')->paginate(10); // Show the page return View::make('site/blog/index', compact('posts')); }
/** * Returns all the blog posts. * * @return View */ public function getIndex() { // $home = $this->post->where('slug', '=', 'home')->first(); // if(count($home) == 1){ // return Theme::make('site/blog/home', compact('home')); // } else { $posts = $this->post->orderBy('created_at', 'DESC')->paginate(10); return Theme::make('site/blog/index', compact('posts')); // } }
/** * Returns all the blog posts. * * @return View */ public function getIndex() { //Cart::add('293ad', 'Product 1', 1, 9.99, array('size' => 'large')); //Cart::remove('0f6524cc3c576d484150599b3682251c'); ///print_r(Cart::content()); //echo Cart::total(); //exit; // Get all the blog posts $posts = $this->post->orderBy('created_at', 'DESC')->paginate(10); // Show the page return View::make('site/blog/index', compact('posts')); }
public function getIndex() { $posts = Post::orderBy('id', 'desc')->paginate(10); $posts->getEnvironment()->setViewName('pagination::simple'); $this->layout->title = 'Home Page | Laravel 4 Blog'; $this->layout->main = View::make('home')->nest('content', 'index', compact('posts')); }
/** * Show a list of all the blog posts. * * @return View */ public function getIndex() { // Grab all the blog posts $posts = Post::orderBy('created_at', 'DESC')->paginate(10); // Show the page return View::make('admin/blogs/index', compact('posts')); }
/** * Display a listing of latest questions. * * @return Response */ public function index() { $sort = array('name' => '', 'direction' => ''); switch (Input::get('sort')) { case 'newest': $sort['name'] = 'created_at'; $sort['direction'] = 'desc'; break; case 'oldest': $sort['name'] = 'created_at'; $sort['direction'] = 'asc'; case 'most viewed': $sort['name'] = 'view_count'; $sort['direction'] = 'desc'; break; default: $sort['name'] = 'created_at'; $sort['direction'] = 'desc'; break; } $questions = Post::orderBy($sort['name'], $sort['direction'])->where('post_type_id', '=', '1')->paginate(10); $tags = Tag::all(); $data = array('questions' => $questions, 'tags' => $tags); // return var_dump($posts); return View::make('public.questions.index', $data); }
public function adminIndexAll() { $posts = Post::orderBy('updated_at', 'desc')->paginate(); return View::make('admin.dicts.list', ['columns' => ['ID', 'Пользователь', 'Текст', 'Рубрика', 'Лайки', 'Комментарии', 'Время', '', ''], 'data' => $posts->transform(function ($post) { return ['id' => $post->id, 'user' => link_to("admin/users{$post->user_id}", $post->user->name), 'text' => link_to("admin/posts/{$post->id}/edit", $post->text), 'category' => link_to("/admin/categories/{$post->category_id}/edit", $post->category->title), 'likes' => link_to("admin/posts/{$post->id}/likes", $post->likes->count()), 'comments' => link_to("admin/posts/{$post->id}/comments", $post->comments->count()), 'time' => Carbon::createFromTimestamp($post->created_at), 'edit' => link_to("/admin/posts/{$post->id}/edit", 'редактировать'), 'delete' => link_to("/admin/posts/{$post->id}/delete", 'удалить')]; }), 'actions' => [['link' => 'admin/posts/delete', 'text' => 'Удалить выбранное']], 'links' => $posts->links(), 'title' => 'Посты']); }
public function run() { $faker = Faker\Factory::create(); DB::table('favorites')->truncate(); foreach (range(1, 30) as $index) { $post = Post::orderBy(DB::raw('RAND()'))->first(); User::orderBy(DB::raw('RAND()'))->first()->favorites()->attach($post->id); } }
public function search() { //TODO Rate limit $query = Input::get('query'); $max = Input::has('size') && Input::get('size') < 61 ? Input::get('size') : 25; $last = Input::has('last') ? Input::get('last') : Post::orderBy('id', 'desc')->first()->id; $posts = Post::where('text', 'ilike', '%' . $query . '%')->where('id', '<', $last)->orderBy('id', 'desc')->with('user', 'likes', 'comments', 'images', 'geos', 'cars', 'cars.images', 'category')->take($max)->get(); return $this->respond($this->collectionTransformer->transformPosts($posts)); }
/** @test **/ public function it_orders_the_values() { $this->createPostsTable(); $this->insertOn('posts', ['title' => 'House', 'content' => 'Repeating']); $this->insertOn('posts', ['title' => 'Sherlock', 'content' => 'Elementary Watson.']); $this->insertOn('posts', ['title' => 'Psych!', 'content' => 'Repeating']); $posts = Post::orderBy('title', 'DESC')->get(); $this->assertEquals('Sherlock', $posts->first()->title); $this->assertEquals('House', $posts->last()->title); }
public function APIGetImages() { $posts = Post::orderBy('id', 'DESC')->where('group_id', $this->id)->get(); $returnStr = array(); foreach ($posts as $post) { if ($post->statustype == 'image') { $returnStr[] = $post->displayAPIMontage(); } } return $returnStr; }
/** * Display a listing of videos * * @return Response */ public function index() { $search_value = Input::get('s'); if (!empty($search_value)) { $posts = Post::where('title', 'LIKE', '%' . $search_value . '%')->orderBy('created_at', 'desc')->paginate(10); } else { $posts = Post::orderBy('created_at', 'DESC')->paginate(10); } $user = Auth::user(); $data = array('posts' => $posts, 'user' => $user, 'admin_user' => Auth::user()); return View::make('admin.posts.index', $data); }
public function rankings() { //Top 10 usuarios $top10user = UserProfile::orderBy('points', 'desc')->take(10)->get(); //Top 10 mejores publicaciones - Todo el tiempo $top10post = Post::orderBy('point', 'desc')->take(10)->get(); //Top 10 mejores publicaciones - Mes $top10month = Post::where('created_at', '>=', new DateTime('-1 months'))->orderBy('point', 'desc')->take(10)->get(); //Top 10 mejores publicaciones - Mes $top10week = Post::where('created_at', '>=', new DateTime('-1 weeks'))->orderBy('point', 'desc')->take(10)->get(); return View::make('ranking', ['top10user' => $top10user, 'top10post' => $top10post, 'top10month' => $top10month, 'top10week' => $top10week]); }
public function blog() { $this->load->model('post'); $this->load->library('pagination'); $posts = Post::all(); $config['base_url'] = base_url() . 'blog/page/'; $config['total_rows'] = $posts->count(); $config['per_page'] = 5; $skip = ($this->uri->segment(3) - 1) * $config['per_page']; $this->pagination->initialize($config); $data = ['menu' => 'blog', 'posts' => Post::orderBy('created_at', 'desc')->skip($skip)->take($config['per_page'])->get(), 'links' => $this->pagination->create_links()]; $this->load->view('front/blog', $data); }
public function trending() { $data['page'] = 'trending'; $data['pagetype'] = 'trending'; $data['images'] = Post::select('posts.*', DB::raw('count(votes.id) as total'))->leftJoin('votes', 'posts.id', '=', 'votes.post_id')->groupBy('posts.id')->orderBy('total', 'desc'); if (Auth::user()) { $data['images'] = $data['images']->with(array('votes' => function ($query) { $query->where('user_id', Auth::id()); }))->take(12)->get(); } else { $data['images'] = $data['images']->take(12)->get(); } $data['others'] = Post::orderBy(DB::raw('RAND()'))->take(10)->get(); return View::make('scrollpost')->with($data); }
/** * Display a listing of the resource. * * @return Response */ public function index() { /*$posts = Post::all(); $this->layout->title = 'Liste des articles'; $this->layout->main = View::make('dash')->nest('content','posts.index',compact('posts'));*/ $sortby = Input::get('sortby'); $order = Input::get('order'); if ($sortby && $order) { $posts = Post::orderBy($sortby, $order)->paginate(10); } else { $posts = Post::orderBy('created_at', 'DESC')->paginate(10); } $this->layout->title = 'Liste des articles'; $this->layout->main = View::make('dash')->nest('content', 'posts.index', compact('posts', 'sortby', 'order')); }
/** * Search * */ public function search() { if (isset($_POST["submitSearch"])) { $find = $_POST['searchBlog']; $getData = Post::all(); $temp = array(); if ($find != "") { foreach ($getData as $data) { $pos = strpos($data['title'], $find); if ($pos !== false) { $temp[] = $data; } } $posts1 = $this->post->orderBy('created_at', 'DESC')->paginate(10); return View::make('site/blog/index')->with(['posts' => $temp, 'posts1' => $posts1]); } else { if ($find == "") { $posts = $this->post->orderBy('created_at', 'DESC')->paginate(10); $posts1 = $this->post->orderBy('created_at', 'DESC')->paginate(10); return View::make('site/blog/index', compact('posts', 'posts1')); } } } }
public function post_all() { $data['post'] = Post::orderBy('id', 'desc')->paginate(11); $data['phan_loai'] = '.phan-loai-0'; return View::make('admin.content', $data); }
public function getUserImages() { $user = Auth::user(); $groups = $user->getGroups(); $images = array(); foreach ($groups as $group) { $posts = Post::orderBy('id', 'DESC')->where('group_id', $group->id)->where('user_id', $user->id)->get(); foreach ($posts as $post) { if ($post->statustype == 'image') { if ($img = $post->displayAPIMontage()) { $images[] = $img; } } } } return Response::json($images); }
public function post($slug) { $post = Post::withTrashed()->where('slug', $slug)->first(); $nextpost = Post::where('id', '<', $post->id)->orderBy('id', 'desc')->first(); if (empty($post)) { App::abort(404); } $comments = Comment::where('post_id', $post->id)->where('parent_comment_id', 0)->orderBy('created_at', 'desc')->take(3)->get(); $attack_comments = Comment::where('post_id', $post->id)->where('type', 'attack')->where('parent_comment_id', 0)->orderBy('created_at', 'desc')->take(3)->get(); $assist_comments = Comment::where('post_id', $post->id)->where('type', 'assist')->where('parent_comment_id', 0)->orderBy('created_at', 'desc')->take(3)->get(); $defense_comments = Comment::where('post_id', $post->id)->where('type', 'defense')->where('parent_comment_id', 0)->orderBy('created_at', 'desc')->take(3)->get(); $post->load(array('votes' => function ($query) { $query->where('user_id', Auth::id()); })); $others = Post::orderBy(DB::raw('RAND()'))->take(10)->get(); $user = User::find($post->user_id); $totalposts = Post::where('user_id', $user->id)->count(); if (!$totalposts) { $totalposts = 0; } $badge = Badge::where('total_posts', '<=', $totalposts)->orderBy('total_posts', 'desc')->first(); if ($badge) { $badgename = $badge->name; $badgeimage = $badge->image; } else { $badgename = ''; $badgeimage = ''; } $featured = FeaturedPost::where('post_id', $post->id)->first(); $data = array('page' => 'page', 'post' => $post, 'nextpost' => $nextpost, 'comments' => $comments, 'attacks' => $attack_comments, 'assists' => $assist_comments, 'defenses' => $defense_comments, 'others' => $others, 'posted_by' => $user->username, 'badge_name' => $badgename, 'badge_image' => $badgeimage, 'isfeatured' => !empty($featured) ? true : false); return View::make('post2')->with($data); }
public function testOrderByTranslated() { Post::forceCreate(['title' => 'Title 1']); Post::forceCreate(['title' => 'Title 2']); $this->assertEquals('Title 2', Post::orderBy('title', 'desc')->first()->title); }
public function index() { $posts = Post::orderBy('point', 'desc')->get(); return View::make('post.index', ['posts' => $posts]); }
public function moderatePost() { $post = Post::orderBy('created_at', 'desc')->distinct()->paginate(10); return View::make('moderate.post')->with('title', "Posts Management")->with('page', "posts")->with('posts', $post); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $posts = Post::orderBy('id', 'DESC')->get(); return View::make('admin.teacher.posts.postsIndex')->with(compact('posts')); }
public function listPost() { $posts = Post::orderBy('id', 'desc')->paginate(10); $this->layout->title = 'Post listings'; $this->layout->main = View::make('dash')->nest('content', 'posts.list', compact('posts')); }
/* User routes */ Route::get('/post/{post}/show', ['as' => 'post.show', 'uses' => 'PostController@showPost']); Route::post('/post/{post}/comment', ['as' => 'comment.new', 'uses' => 'CommentController@newComment']); /* Admin routes */ Route::group(['prefix' => 'admin', 'before' => 'auth'], function () { /*get routes*/ Route::get('dash-board', function () { $layout = View::make('master'); $layout->title = 'DashBoard'; $username = Auth::user()->username; $layout->main = View::make('dash')->with('content', "Hi {$username}, Welcome to Dashboard!"); return $layout; }); Route::get('/post/list', ['as' => 'post.list', 'uses' => 'PostController@listPost']); Route::get('/post/new', ['as' => 'post.new', 'uses' => 'PostController@newPost']); Route::get('/post/{post}/edit', ['as' => 'post.edit', 'uses' => 'PostController@editPost']); Route::get('/post/{post}/delete', ['as' => 'post.delete', 'uses' => 'PostController@deletePost']); Route::get('/comment/list', ['as' => 'comment.list', 'uses' => 'CommentController@listComment']); Route::get('/comment/{comment}/show', ['as' => 'comment.show', 'uses' => 'CommentController@showComment']); Route::get('/comment/{comment}/delete', ['as' => 'comment.delete', 'uses' => 'CommentController@deleteComment']); /*post routes*/ Route::post('/post/save', ['as' => 'post.save', 'uses' => 'PostController@savePost']); Route::post('/post/{post}/update', ['as' => 'post.update', 'uses' => 'PostController@updatePost']); Route::post('/comment/{comment}/update', ['as' => 'comment.update', 'uses' => 'CommentController@updateComment']); }); /* Home routes */ Route::controller('/', 'BlogController'); /* View Composer */ View::composer('sidebar', function ($view) { $view->recentPosts = Post::orderBy('id', 'desc')->take(5)->get(); });
/** * Display a listing of the resource. * GET /addimages * * @return Response */ public function index() { $images = Post::orderBy('created_at', 'desc')->paginate(20); return View::make('admins.images.index', compact('images')); }
public function viewposts() { $posts = Post::orderBy('created_at', 'desc')->get(); if (Auth::user()->role == 'admin' || Auth::user()->role == 'teacher') { $this->layout->content = View::make('posts.viewposts')->with('posts', $posts); } else { return View::make('posts.viewposts-kids')->with('posts', $posts); } }
public function ajax_loading_category() { $offset = is_numeric(Input::get('offset')) ? Input::get('offset') : die; $postnumbers = is_numeric(Input::get('number')) ? Input::get('number') : die; $id = Input::get('category_id'); Log::info('num' . $postnumbers); Log::info('offset' . $offset); $query = Post::orderBy('created_at', 'desc')->distinct()->where('is_approved', 1)->where('category', 'LIKE', '%' . $id . '%')->limit($postnumbers)->offset($offset)->get(); $data = $query; foreach ($data as $post) { $cat_name = $post->share_cat; $fb = route("shareLink", array("id" => $cat_name, "data" => $post->link)); $twitter = route("shareLink", array("id" => $cat_name, "data" => $post->link)); echo '<div class="col m6 s12 l4"> <div class="single-post card animated zoomIn"> <div class="card-image"> <a href="javascript:void(0);"><img src="' . $post->image . '"></a> <span class="card-title">' . $post->title . '<em class="time-ago right">' . $post->created_at->diffForHumans() . '</em></span> </div> <div class="card-content"> <p class="text-justify">' . $post->des . '</p> </div> <div class="card-action text-center"> <a target="_blank" href="http://www.facebook.com/sharer.php?u=' . $fb . '" class="full waves-effect waves-light btn light-blue darken-4"><i class="fa fa-facebook left"></i>Share on Facebook</a> <a target="_blank" href="http://twitter.com/share?text=' . substr($post->title, 0, 30) . '...&url=' . $twitter . '" class="full waves-effect waves-light btn no-right-mar light-blue accent-3"><i class="fa fa-twitter left"></i>Share on Twitter</a> <a target="_blank" href="' . $post->url . '" target="_blank" class="full-btn waves-effect waves-light btn no-right-mar mat-clr">Read More </a> </div> </div> </div>'; } }
public function api_hybrid_feed() { $offset = is_numeric(Input::get('offset')) ? Input::get('offset') : die; $postnumbers = is_numeric(Input::get('number')) ? Input::get('number') : die; $query = ""; $query = Post::orderBy('id', 'desc')->distinct()->where('is_approved', 1)->limit($postnumbers)->offset($offset)->get(); $data = $query; foreach ($data as $post) { echo '<div class="section fp-section fp-table"><div class="fp-tableCell"> <div class="swiper-slide"> <div class="news-box"> <div class="img-container"> <img src="' . $post->image . '"> <div class="bottom-nav"> <h6>' . $post->created_at->diffForHumans() . '</h6> <a href="javascript:void(0);" onclick="window.plugins.socialsharing.share(\'' . $post->title . '\', null, null, \'http://www.x-services.nl\')" class="icon right"><i class="fa fa-share"></i></a> </div> </div> <div class="conent-container"> <h4>' . $post->title . '</h4> <p>' . $post->des . '</p> <div class="read"> <a href="javascript:void(0);" onclick="open_this_url(url);"><i class="fa fa-circle"></i> <i class="fa fa-circle"></i> <i class="fa fa-circle"></i></a> </div> </div> </div> </div></div></div>'; } }