Commit f4518035 by hfpp2012 yinsigan

seed & foreach

1 parent 8685b790
......@@ -9,17 +9,7 @@ class UsersController extends Controller
{
public function index()
{
$users = [
'0' => [
'first_name' => 'Renato',
'last_name' => 'Hysa'
],
'1' => [
'first_name' => 'Jessica',
'last_name' => 'Alba'
]
];
// return $users;
$users = User::all();
return view('admin.users.index', compact('users'));
}
......
......@@ -11,6 +11,7 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
factory(App\User::class, 100)->create();
// $this->call(UsersTableSeeder::class);
}
}
<ul>
@foreach($users as $user)
<li>{{ $user['first_name'] }} {{ $user['last_name'] }}</li>
@endforeach
</ul>
@extends('layouts.app')
@section('content')
<div class="row">
<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!