public function getIndex() { $title = "Artículos"; $articles = Article::orderBy('name', 'asc')->paginate(6); $branches = Branche::orderBy('name', 'asc')->get(); return View::make('articles.index')->with(compact('articles', 'title', 'branches')); }
/** * Page d'accueil * * @access public * @return View home.home */ public function home() { // Fetch latest articles $articles = Article::orderBy('created_at', 'DESC')->paginate(5); // Fetch latest torrents $torrents = Torrent::orderBy('created_at', 'DESC')->take(5)->get(); // Fetch latest topics $topics = Topic::orderBy('created_at', 'DESC')->take(5)->get(); // Fetch latest registered users $users = User::orderBy('created_at', 'DESC')->take(5)->get(); return View::make('home.home', array('articles' => $articles, 'torrents' => $torrents, 'topics' => $topics, 'users' => $users)); }
/** * Show search result * @return response */ public function search() { $query = Article::orderBy('created_at', 'desc')->where('post_status', 'open'); $categories = Category::orderBy('sort_order')->get(); // Get search conditions switch (Input::get('target')) { case 'title': $title = Input::get('like'); break; } // Construct query statement isset($title) and $query->where('title', 'like', "%{$title}%")->orWhere('content', 'like', "%{$title}%"); $articles = $query->paginate(6); return View::make('article.search')->with(compact('articles', 'categories')); }
/** * View: Video Index * @return Respanse */ public function getVideoIndex() { $articles = Article::orderBy('created_at', 'desc')->where('post_status', 'open')->paginate(6); $travel = Travel::orderBy('created_at', 'desc')->where('post_status', 'open')->paginate(4); $product = Product::orderBy('created_at', 'desc')->where('post_status', 'open')->where('quantity', '>', '0')->paginate(12); $productCategories = ProductCategories::orderBy('sort_order')->where('cat_status', 'open')->get(); $job = Job::orderBy('created_at', 'desc')->where('post_status', 'open')->paginate(4); $categories = Category::orderBy('sort_order')->where('cat_status', 'open')->get(); if (Auth::check()) { $timeline = Timeline::orderBy('created_at', 'desc')->where('user_id', Auth::user()->id)->paginate(6); } else { $timeline = Timeline::orderBy('created_at', 'desc'); } return View::make('home.videoindex')->with(compact('articles', 'categories', 'travel', 'product', 'productCategories', 'job', 'timeline')); }
public function showWelcome() { $gethealth = Category::where('category', 'Health')->first()->id; $getEntertainment = Category::where('category', 'Entertainment')->first()->id; $entertainmentArticles = Article::where('category_id', $getEntertainment)->orderBy('created_at', 'DESC')->get(); $healthArticles = Article::where('category_id', $gethealth)->orderBy('created_at', 'DESC')->get(); $getlifstyle = Category::where('category', 'Lifestyle')->first()->id; $latestArticles = Article::orderBy('created_at', 'DESC')->take(10)->get(); $articles = Article::where('category_id', $getlifstyle)->orderBy('created_at', 'DESC')->take(10)->get(); $entertainmentHeader = $entertainmentArticles->take(1); $eArticles = $entertainmentArticles->take(4)->slice(1); $slides = $latestArticles->take(4); $related = $articles->take(2); $small = $articles->slice(2)->take(6); $gethealthArticle = $healthArticles->take(1); $smallHealthArticles = $healthArticles->take(4)->slice(1); return View::make('home')->with('slides', $slides)->with('latestArticles', $latestArticles)->with('related', $related)->with('articles', $articles)->with('small', $small)->with('gethealthArticle', $gethealthArticle)->with('smallHealthArticles', $smallHealthArticles)->with('entertainmentHeader', $entertainmentHeader)->with('eArticles', $eArticles); }
|-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ Route::get('/', 'HomeController@showWelcome'); Route::get('login', 'AuthController@getUserLogin'); Route::post('login', 'AuthController@postUserLogin'); Route::get('logout', 'AuthController@userLogout'); Route::get('admin/login', 'AuthController@getAdminLogin'); Route::post('admin/login', 'AuthController@postAdminLogin'); Route::any('admin/logout', 'AuthController@AdminLogout'); Route::get('api/articles', function () { $articles = Article::orderBy('created_at', 'DESC')->get(); return $articles; }); Route::get('api/categories', function () { $categories = Category::all(); return $categories; }); Route::get('/article/{slug}', array('uses' => 'ArticlesController@show', 'as' => 'article.show')); Route::group(['prefix' => '/dashboard', 'before' => 'auth.admin'], function () { Route::post('/category/add', array('uses' => 'AdminsController@AddCategory', 'as' => 'add.category')); //Article Routes Route::get('/article/all', array('uses' => 'ArticlesController@index', 'as' => 'article.index')); Route::get('/article/create', array('uses' => 'ArticlesController@create', 'as' => 'article.create')); Route::post('/article', array('uses' => 'ArticlesController@store', 'as' => 'article.store')); Route::get('/article/{slug}/edit', array('uses' => 'ArticlesController@edit', 'as' => 'article.edit')); Route::put('/article/{slug}', array('uses' => 'ArticlesController@update', 'as' => 'article.update'));
<?php // Home page Route::get('/', array('as' => 'home', function () { return View::make('site::index')->with('entry', Page::where('slug', 'welcome')->first()); })); // Article list Route::get('blog', array('as' => 'article.list', function () { return View::make('site::articles')->with('entries', Article::orderBy('created_at', 'desc')->get()); })); // Single article Route::get('blog/{slug}', array('as' => 'article', function ($slug) { $article = Article::where('slug', $slug)->first(); if (!$article) { App::abort(404, 'Article not found'); } return View::make('site::article')->with('entry', $article); })); // Single page Route::get('{slug}', array('as' => 'page', function ($slug) { $page = Page::where('slug', $slug)->first(); if (!$page) { App::abort(404, 'Page not found'); } return View::make('site::page')->with('entry', $page); }))->where('slug', '^((?!admin).)*$'); // 404 Page App::missing(function ($exception) { return Response::view('site::404', array(), 404); });
/** * 博客首页 * @return Respanse */ public function getIndex() { $articles = Article::orderBy('created_at', 'desc')->paginate(5); $categories = Category::orderBy('sort_order')->get(); return View::make('blog.index')->with(compact('articles', 'categories')); }
public function index() { $articles = Article::orderBy('published', 'ASC')->orderBy('created_at', 'DESC')->get(); return Response::json($articles); }
/** * Affiche les articles comme en page d'accueil * * @access public * @return post.articles */ public function articles() { // Fetch posts by created_at DESC order $articles = Article::orderBy('created_at', 'DESC')->paginate(5); return View::make('article.articles', array('articles' => $articles)); }
}]); Route::post('RemindersController', ['as' => 'RemindersController', 'uses' => 'RemindersController@postReset']); /*Route::controller('password', 'RemindersController'); Password::remind(Input::only('email'), function($message) { $message->subject('Password Reminder'); });*/ /* route cms*/ Route::get('cms', function () { return View::make('layouts.cms'); }); /* route article.list */ Route::group(['prefix' => 'cms/article/'], function () { Route::get('', ['as' => 'article.list', function () { $articles = Article::orderBy('id', 'desc')->paginate(5); return View::make('cms.article.list')->with('articles', $articles); }]); /* route article.add */ Route::get('add', ['as' => 'article.add', function () { return View::make('cms.article.add'); }]); /* route article.insert.validation */ Route::post('insert', ['as' => 'article.insert', function () { $rules = ['date' => 'required|max:255|date', 'title' => 'required|max:255|unique:article', 'publish' => 'required|boolean']; $validation = Validator::make(Input::all(), $rules); if ($validation->fails()) { Input::flash(); return Redirect::route('article.add')->withErrors($validation); } $article = new Article();