Skip to content

Commit 30a8cd3

Browse files
committed
working on view docs
1 parent 2e64e52 commit 30a8cd3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

views.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ A simple view might look something like this:
2222

2323
Since this view is stored at `resources/views/greeting.php`, we may return it using the global `view` helper function like so:
2424

25-
Route::get('/', function () {
25+
Route::get('/', function () {
2626
return view('greeting', ['name' => 'James']);
2727
});
2828

29-
As you can see, the first argument passed to the `view` helper corresponds to the name of the view file in the `resources/views` directory. The second argument passed to helper is an array of data that should be made available to the view. In this case, we are passing the `name` variable, which is displayed in the view by simply executing `echo` on the variable.
29+
As you can see, the first argument passed to the `view` helper corresponds to the name of the view file in the `resources/views` directory. The second argument passed to helper is an array of data that should be made available to the view. In this case, we are passing the `name` variable, which is displayed in the view by executing `echo` on the variable.
3030

3131
Of course, views may also be nested within sub-directories of the `resources/views` directory. "Dot" notation may be used to reference nested views. For example, if your view is stored at `resources/views/admin/profile.php`, you may reference it like so:
3232

@@ -54,12 +54,12 @@ As you saw in the previous examples, you may easily pass an array of data to vie
5454

5555
When passing information in this manner, `$data` should be an array with key/value pairs. Inside your view, you can then access each value using its corresponding key, such as `<?php echo $key; ?>`. As an alternative to passing a complete array of data to the `view` helper function, you may use the `with` method to add individual pieces of data to the view:
5656

57-
$view = view('greeting')->with('name', 'Victoria');
57+
return view('greeting')->with('name', 'Victoria');
5858

5959
<a name="sharing-data-with-all-views"></a>
6060
#### Sharing Data With All Views
6161

62-
Occasionally, you may need to share a piece of data with all views that are rendered by your application. You may do so using the view factory's `share` method. Typically, you would place calls to `share` within a service provider's `boot` method. You are free to add them to the `AppServiceProvider` or generate a separate service provider to house them:
62+
Occasionally, you may need to share a piece of data with all views that are rendered by your application. You may do so using the view factory's `share` method. Typically, you should place calls to `share` within a service provider's `boot` method. You are free to add them to the `AppServiceProvider` or generate a separate service provider to house them:
6363

6464
<?php
6565

@@ -117,7 +117,7 @@ Let's register our view composers within a [service provider](/docs/{{version}}/
117117

118118
// Using Closure based composers...
119119
view()->composer('dashboard', function ($view) {
120-
120+
//
121121
});
122122
}
123123

@@ -140,7 +140,7 @@ Now that we have registered the composer, the `ProfileComposer@compose` method w
140140

141141
namespace App\Http\ViewComposers;
142142

143-
use Illuminate\Contracts\View\View;
143+
use Illuminate\View\View;
144144
use Illuminate\Users\Repository as UserRepository;
145145

146146
class ProfileComposer
@@ -176,7 +176,7 @@ Now that we have registered the composer, the `ProfileComposer@compose` method w
176176
}
177177
}
178178

179-
Just before the view is rendered, the composer's `compose` method is called with the `Illuminate\Contracts\View\View` instance. You may use the `with` method to bind data to the view.
179+
Just before the view is rendered, the composer's `compose` method is called with the `Illuminate\View\View` instance. You may use the `with` method to bind data to the view.
180180

181181
> **Note:** All view composers are resolved via the [service container](/docs/{{version}}/container), so you may type-hint any dependencies you need within a composer's constructor.
182182

0 commit comments

Comments
 (0)