1、怎样输出视图
namespace App\Http\Controllers;
class MemberController extends Controller {
public function index() {
return view('member');
}
}
Route::get('member/index', 'MemberController@index');
2、一个控制器对应一个view文件夹
app/Http/Controllers/MemberController.php
namespace App\Http\Controllers;
class MemberController extends Controller {
public function index() {
return view('member/member');
}
}
app/Http/routes.php
Route::get('member/index', 'MemberController@index');
resources/views/member/member.blade.php
my name is member
3、将控制器的数据输出到视图文件上
Route::get('member/index', 'MemberController@index');
namespace App\Http\Controllers;
class MemberController extends Controller {
public function index() {
return view('member/member', [
'name' => 'gengen',
'age' => 18
]);
}
}
my name is member
{{$name}}
{{$age}}
4、循环数据
@foreach($all_knowledge as $key => $value)
{{$value->title}}
@endforeach
5、页面跳转
return redirect('/uploadknowledge');