示例#1
0
文件: routes.php 项目: avilaj/ocsport
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| 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 controller to call when that URI is requested.
|
*/
use Illuminate\Http\Request;
$categories = App\Category::whereNotIn('id', [1])->get();
View::share('categories', $categories);
$configuracion = new App\Configuration();
View::share('configuration', $configuracion);
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::get('/', function () use($configuracion) {
    setlocale(LC_TIME, 'es_ES.utf8');
    $homeBanner = App\Gallery::find(intval($configuracion->home_slider));
    $homeCollectionBanner = App\Gallery::tag('home_collection_banner');
    return view('pages.home', ['products' => App\Product::with('colors', 'category')->orderBy('created_at', 'desc')->take(3)->get(), 'news' => App\News::orderBy('created_at', 'desc')->take(2)->get(), 'home_banner' => $homeBanner, 'home_collection_banner' => $homeCollectionBanner]);
});
Route::get('/productos', function (Request $request) {
    $category = App\Category::with('gallery')->where('slug', 'productos')->first();
    $productos = App\Product::with('colors');
    $search = $request->input('s');
    if (isset($search) && !empty($search)) {
        $productos->where('title', 'like', "%{$search}%")->orWhere('subtitle', 'like', "%{$search}%");
    }