Commit f4518035 by hfpp2012 yinsigan

seed & foreach

1 parent 8685b790
...@@ -9,17 +9,7 @@ class UsersController extends Controller ...@@ -9,17 +9,7 @@ class UsersController extends Controller
{ {
public function index() public function index()
{ {
$users = [ $users = User::all();
'0' => [
'first_name' => 'Renato',
'last_name' => 'Hysa'
],
'1' => [
'first_name' => 'Jessica',
'last_name' => 'Alba'
]
];
// return $users;
return view('admin.users.index', compact('users')); return view('admin.users.index', compact('users'));
} }
......
...@@ -11,6 +11,7 @@ class DatabaseSeeder extends Seeder ...@@ -11,6 +11,7 @@ class DatabaseSeeder extends Seeder
*/ */
public function run() public function run()
{ {
factory(App\User::class, 100)->create();
// $this->call(UsersTableSeeder::class); // $this->call(UsersTableSeeder::class);
} }
} }
<ul> @extends('layouts.app')
@foreach($users as $user)
<li>{{ $user['first_name'] }} {{ $user['last_name'] }}</li> @section('content')
@endforeach <div class="row">
</ul> <div class="col-md-6 col-md-offset-3">
<ul class='list-group'>
@foreach($users as $user)
<li class='list-group-item' style="margin-top: 20px;">
<span>{{ $user->name }}</span>
<span class="pull-right clearfix">
Joined ({{ $user->created_at->diffForHumans() }})
</span>
<button class='btn btn-xs btn-primary'>Follow</button>
</li>
@endforeach
</ul>
</div>
</div>
@endsection
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!