Skip to content

Commit cb84170

Browse files
committed
Update sharing docs
1 parent 5b5f9b3 commit cb84170

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,24 @@ Inertia::share('auth.user', function () {
136136
];
137137
}
138138
});
139+
140+
// Multiple values
141+
Inertia::share([
142+
// Synchronously
143+
'app' => [
144+
'name' => Config::get('app.name')
145+
],
146+
// Lazily
147+
'auth' => function () {
148+
return [
149+
'user' => Auth::user() ? [
150+
'id' => Auth::user()->id,
151+
'first_name' => Auth::user()->first_name,
152+
'last_name' => Auth::user()->last_name,
153+
] : null;
154+
];
155+
}
156+
]);
139157
~~~
140158

141159
You can also get shared data using the same method `Inertia::share($key)`. If the key is not found, `null` is returned.

0 commit comments

Comments
 (0)