laravel建立一个分组控制器和分组路由
Posted 与f
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了laravel建立一个分组控制器和分组路由相关的知识,希望对你有一定的参考价值。
路由
Route::group([‘domain‘ => ‘laravel.8g.com‘,‘namespace‘ => ‘Admin‘],function() { Route::get(‘/admin/login‘,‘[email protected]‘); Route::post(‘/admin/signin‘,‘[email protected]‘); });
控制器(Http\Controllers\Admin\LoginController.php)
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2017/11/5 * Time: 14:08 */ namespace App\Http\Controllers\Admin; use App\User; use Illuminate\Http\Request; use App\Http\Controllers\Controller; class LoginController extends Controller { public function login() { return view("login/login"); } public function signin(Request $request) { var_dump($request->all()); $username = $request->input("username"); $password = $request->input(‘password‘); var_dump($username); var_dump($password); return view("login/signin"); } }
模板(reeources\views\login\login.blade.php)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>test</title> </head> <body> <form method="post" action="{{ url(‘/admin/signin‘) }}"> <input name="username" type="text" value=""/> <input name="password" type="text" value=""/> <input type="hidden" name="_token" value="{{ csrf_token() }}" /> <input type="submit" value="提交"> </form> </body> </html>
以上是关于laravel建立一个分组控制器和分组路由的主要内容,如果未能解决你的问题,请参考以下文章