06.10.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Package Development 407<br />

Routing<br />

To define routes for your package, simply require the routes file from within your package service<br />

provider’s boot method. From within your routes file, you may use the Route facade to register<br />

routes just as you would within a typical Laravel application:<br />

1 /**<br />

2 * Perform post-registration booting of services.<br />

3 *<br />

4 * @return void<br />

5 */<br />

6 public function boot()<br />

7 {<br />

8 if (! $this->app->routesAreCached()) {<br />

9 require __DIR__.'/../../routes.php';<br />

10 }<br />

11 }<br />

Resources<br />

Views<br />

To register your package’s views with Laravel, you need to tell Laravel where the views are located.<br />

You may do this using the service provider’s loadViewsFrom method. The loadViewsFrom method<br />

accepts two arguments: the path to your view templates and your package’s name. For example, if<br />

your package name is “courier”, add the following to your service provider’s boot method:<br />

1 /**<br />

2 * Perform post-registration booting of services.<br />

3 *<br />

4 * @return void<br />

5 */<br />

6 public function boot()<br />

7 {<br />

8 $this->loadViewsFrom(__DIR__.'/path/to/views', 'courier');<br />

9 }

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!