laravel的路由
作者:互联网
laravel的每个操作都要写一个路由
laravel的路由要写在routes里的web.php
代码如下
use App\Http\Resources\User as UserResource; use App\Model\Test\User; //Route::get('/', function () { // return view('welcome'); //}); //Route::get('/haha', function () { // return 'hehehe'; //}); Route::get('/',function (){ return view('welcome'); }); Route::get('/a','Admin\AdminController@hello'); //闭包函数 //use Illuminate\Support\Facades\View; Route::get('/',function() { // return view('weloce'); //转换为json // return[ // 'a' =>'aaaa', // 'b'=>'bbbb' // ]; //转换为数组 // return [1, 2, 3]; //自定义HTTP状态码 // return response('Hello World', 404) // ->header('Content-Type', 'text/plain'); //添加响应头 // return response('$content',200) // ->header('Content-Type', 'text/plain'); //添加cookie到响应 // return response('$content',200) // ->header('Content-Type', 'a=10'); //跳转页面 // return redirect('Admin\UserController@hello'); //返回 // return back()->withInput(); //数组转换为 JSON : // return response()->json([ // 'name' => 'Abigail', // 'state' => 'CA' // ]); //判断视图文件是否存在 // dd(View::exists('emails.customer')); // return view('weloce'); }); //Route::any('users/{id}',"Admin\UserController@hello"); Route::view('text','text.text'); Route::get('/mysql','UserController@index'); Route::get('/model','UserController@test'); Route::any('/res',function (){ return new UserResource(User::find(1)); }); Route::get('/get','TestController@get'); Route::view('index','index'); Route::view('img','alert'); Route::any('user/{a?}',"TestController@test")->middleware('test'); //Route::any('users/{id}',"Admin\UserController@hello")->name('h'); //Route::any('users/hello',"Admin\UserController@hello")->name('h'); //
view 如果
标签:laravel,return,get,Route,UserController,hello,路由,view 来源: https://www.cnblogs.com/LQK157/p/11474662.html