laravel控制器
1、怎么新建一个控制器 例子(1) 新建一个控制器类: app/Http/Controllers/MemberController.php namespace App\Http\Controllers; class MemberController extends Controller { public function index() { return route('member'); } } 添加路由: app/Http/routes.php Route::get('member/index', [ 'uses' => 'MemberController@index', 'as' => 'member' ]); 例子(2)传递参数、验证参数 namespace App\Http\Controllers; class MemberController extends Controller { public function index($id) { return $id; } } Route::get('member/{id}', [ 'uses' => 'MemberController@index', 'as' => 'member' ])->where('id', '[0-9]+'); 2、分配数据 return view('phpknowledge.index', [ 'all_knowledge' => $all_knowledge ]);