Commit 21f626f6 by hfpp2012 yinsigan

第一个路由 UsersController

1 parent 1a954577
...@@ -10,14 +10,15 @@ class UsersController extends Controller ...@@ -10,14 +10,15 @@ class UsersController extends Controller
{ {
$users = [ $users = [
'0' => [ '0' => [
'first_name' => 'a', 'first_name' => 'Renato',
'last_name' => 'b' 'last_name' => 'Hysa'
], ],
'1' => [ '1' => [
'first_name' => 'c', 'first_name' => 'Jessica',
'last_name' => 'd' 'last_name' => 'Alba'
] ]
]; ];
return $users; // return $users;
return view('admin.users.index', compact('users'));
} }
} }
<ul>
@foreach($users as $user)
<li>{!! $user['first_name'] !!} {!! $user['last_name'] !!}</li>
@endforeach
</ul>
...@@ -15,16 +15,18 @@ Route::get('/', function () { ...@@ -15,16 +15,18 @@ Route::get('/', function () {
return view('welcome'); return view('welcome');
}); });
Route::get('/users', function () { // Route::get('/users', function () {
$users = [ // $users = [
'0' => [ // '0' => [
'first_name' => 'a', // 'first_name' => 'a',
'last_name' => 'b' // 'last_name' => 'b'
], // ],
'1' => [ // '1' => [
'first_name' => 'c', // 'first_name' => 'c',
'last_name' => 'd' // 'last_name' => 'd'
] // ]
]; // ];
return $users; // return $users;
}); // });
Route::get('/users', ['uses' => 'UsersController@index']);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!