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 957364cc
authored
Aug 14, 2017
by
hfpp2012 yinsigan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
view 中共享数据
1 parent
bc2186e5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletions
app/Providers/AppServiceProvider.php
resources/views/home.blade.php
app/Providers/AppServiceProvider.php
View file @
957364c
...
@@ -3,6 +3,9 @@
...
@@ -3,6 +3,9 @@
namespace
App\Providers
;
namespace
App\Providers
;
use
Illuminate\Support\ServiceProvider
;
use
Illuminate\Support\ServiceProvider
;
use
View
;
use
Carbon\Carbon
;
use
Auth
;
class
AppServiceProvider
extends
ServiceProvider
class
AppServiceProvider
extends
ServiceProvider
{
{
...
@@ -13,7 +16,16 @@ class AppServiceProvider extends ServiceProvider
...
@@ -13,7 +16,16 @@ class AppServiceProvider extends ServiceProvider
*/
*/
public
function
boot
()
public
function
boot
()
{
{
//
$age
=
Carbon
::
createFromDate
(
1993
,
7
,
6
)
->
age
;
View
::
share
(
'age'
,
$age
);
View
::
share
(
'myname'
,
'Renato'
);
// View::share('auth', Auth::user());
View
::
composer
(
'*'
,
function
(
$view
)
{
$view
->
with
(
'auth'
,
Auth
::
user
());
});
}
}
/**
/**
...
...
resources/views/home.blade.php
View file @
957364c
...
@@ -8,6 +8,10 @@
...
@@ -8,6 +8,10 @@
<div
class=
"panel-heading"
>
Dashboard
</div>
<div
class=
"panel-heading"
>
Dashboard
</div>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
<h2>
{{ Auth::user()->name }}
</h2>
<h2>
{{ $myname }}
</h2>
<h2>
{{ $age }}
</h2>
<h2>
{{ $auth->name }}
</h2>
You are logged in!
You are logged in!
</div>
</div>
</div>
</div>
...
...
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