Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
hfpp2012
/
laravel-blog
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f4518035
authored
Sep 06, 2017
by
hfpp2012 yinsigan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
seed & foreach
1 parent
8685b790
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
16 deletions
app/Http/Controllers/UsersController.php
database/seeds/DatabaseSeeder.php
resources/views/admin/users/index.blade.php
app/Http/Controllers/UsersController.php
View file @
f451803
...
...
@@ -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'
));
}
...
...
database/seeds/DatabaseSeeder.php
View file @
f451803
...
...
@@ -11,6 +11,7 @@ class DatabaseSeeder extends Seeder
*/
public
function
run
()
{
factory
(
App\User
::
class
,
100
)
->
create
();
// $this->call(UsersTableSeeder::class);
}
}
resources/views/admin/users/index.blade.php
View file @
f451803
<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
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment