Laravel 创建前台文章页面
Laravel 创建前台隐私协议等页面
-
创建控制器
php artisan make:controller ArticleController// ArticleController.php use Illuminate\Http\Request; public function detail(Request $request) { $id=$request->get('id',3); $detail = Db::table('page')->where(array('id' => $id))->first(); // dd($info); return view('article', compact('detail')); } -
创建视图
touch resources/views/article.blade.php// article.blade.php <!DOCTYPE html> <html lang=""> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <!-- Fonts --> <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@200;600&display=swap" rel="stylesheet"> <!-- Styles --> <style> html, body { background-color: #fff; color: #636b6f; font-family: 'Nunito', sans-serif; font-weight: 200; height: 100vh; margin: 0; } .title { font-size: 2rem; text-align: center; padding: 1rem 0; } .content { width: 80%; margin: 0 auto; } </style> </head> <body> <div class="title"></div> <div class="content">{!! $detail->content !!}</div> </body> </html> -
添加路由routes/web.php
Route::get('article','ArticleController@detail');