예제 #1
0
/*
|--------------------------------------------------------------------------
| 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.
|
*/
//首页
Route::get('/', ['as' => 'home', function () {
    $categories = App\AppCategory::all();
    $platform = 'android';
    $category = 'all';
    $apps = App\App::Paginate(15);
    return view('app')->with(compact('categories', 'apps', 'platform', 'category'));
}]);
//列表
Route::get('/platform/{platform}/category/{category}', ['as' => 'list', function ($platform, $category) {
    $categories = App\AppCategory::all();
    if ($category == 'all') {
        $apps = App\App::where('platform', $platform)->Paginate(15);
    } else {
        $apps = App\App::where('platform', $platform)->where('cid', $category)->Paginate(15);
    }
    return view('app')->with(compact('categories', 'apps', 'platform', 'category'));
}]);
//详情页面
Route::get('/detail/{id}', ['as' => 'detail', function ($id) {
    $app = App\App::findOrFail($id);