Skip to content

Commit

Permalink
Laravel 5.3 support - move file to routes/breadcrumbs.php
Browse files Browse the repository at this point in the history
Partial implementation of d13r#130
  • Loading branch information
d13r committed Aug 28, 2016
1 parent 1c352bc commit 8e64e8e
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[ISSUE_TEMPLATE.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
indent_style = space
4 changes: 2 additions & 2 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ Laravel Breadcrumbs:
Laravel:
PHP:

**Copy of `app/Http/breadcrumbs.php`**
**Copy of `routes/breadcrumbs.php` (or `app/Http/breadcrumbs.php`)**
```php

```

**Copy of `app/Http/routes.php`**
**Copy of `routes/web.php` (or `app/Http/routes.php`)**
```php

```
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ All support requests / bug reports should be submitted using `GitHub issues <htt
- PHP version
- Copies of the following files (you can use `Gist <https://gist.github.com/>`_ if they're very long):

- ``app/Http/breadcrumbs.php``
- ``routes/breadcrumbs.php`` or ``app/Http/breadcrumbs.php``
- ``config/breadcrumbs.php`` (if used)
- The view and/or layout files
- The custom breadcrumbs template (if applicable)
Expand Down
18 changes: 17 additions & 1 deletion docs/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,23 @@ Do not use the following keys in your data array, as they will be overwritten: `
Defining breadcrumbs in a different file
================================================================================

If you don't want to use ``app/Http/breadcrumbs.php``, you can define them in ``app/Http/routes.php`` or any other file as long as it's loaded by Laravel.
If you don't want to use ``routes/breadcrumbs.php`` (or ``app/Http/breadcrumbs.php`` in Laravel 5.2 and below), you can create a custom service provider to use instead of ``DaveJamesMiller\Breadcrumbs\ServiceProvider`` and override the ``registerBreadcrumbs()`` method:

.. code-block:: php
<?php
namespace App\Providers;
use DaveJamesMiller\Breadcrumbs\ServiceProvider;
class BreadcrumbsServiceProvider extends ServiceProvider
{
public function registerBreadcrumbs()
{
require base_path('path/to/breadcrumbs.php');
}
}
If you are creating your own package, simply load them from your service provider's ``boot()`` method:

Expand Down
18 changes: 18 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ Laravel Breadcrumbs uses `Semantic Versioning <http://semver.org/>`_.
.. ================================================================================
================================================================================
v3.0.1_ :date:`(28 Aug 2016)`
================================================================================


- Laravel 5.3 support

.. _v3.0.1: https://github.com/davejamesmiller/laravel-breadcrumbs/tree/3.0.1


----------------------------------------
Upgrading from Laravel 5.2 to 5.3
----------------------------------------

- Upgrade Laravel Breadcrumbs to 3.0.1 (or above)
- Move ``app/Http/breadcrumbs.php`` to ``routes/breadcrumbs.php`` (optional but recommended)


================================================================================
v3.0.0_ :date:`(8 Feb 2015)`
================================================================================
Expand Down
25 changes: 13 additions & 12 deletions docs/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ In normal usage you must call ``Breadcrumbs::render($name, $params...)`` to rend
Name your routes
----------------------------------------

Make sure each of your routes has a name (``'as'`` parameter). For example (``app/Http/routes.php``):
Make sure each of your routes has a name (``'as'`` parameter). For example (``routes/web.php``):

.. code-block:: php
Expand All @@ -28,14 +28,14 @@ Make sure each of your routes has a name (``'as'`` parameter). For example (``ap
// Home > [Page]
Route::get('/page/{id}', ['as' => 'page', 'uses' => 'PageController@show']);
For more details see `Named Routes <http://laravel.com/docs/routing#named-routes>`_ in the Laravel documentation.
For more details see `Named Routes <https://www.laravel.com/docs/5.3/routing#named-routes>`_ in the Laravel documentation.


----------------------------------------
Name your breadcrumbs to match
----------------------------------------

For each route, create a breadcrumb with the same name. For example (``app/Http/routes.php``):
For each route, create a breadcrumb with the same name. For example (``routes/breadcrumbs.php``):

.. code-block:: php
Expand Down Expand Up @@ -80,14 +80,15 @@ Laravel Breadcrumbs uses the same model binding as the controller. For example:

.. code-block:: php
// app/Http/routes.php
// routes/web.php
Route::model('page', 'Page');
Route::get('/page/{page}', ['uses' => 'PageController@show', 'as' => 'page']);
.. code-block:: php
// app/Http/Controllers/PageController.php
class PageController extends Controller {
class PageController extends Controller
{
public function show($page)
{
return view('page/show', ['page' => $page]);
Expand All @@ -96,7 +97,7 @@ Laravel Breadcrumbs uses the same model binding as the controller. For example:
.. code-block:: php
// app/Http/breadcrumbs.php
// routes/breadcrumbs.php
Breadcrumbs::register('page', function($breadcrumbs, $page)
{
$breadcrumbs->parent('home');
Expand All @@ -105,7 +106,7 @@ Laravel Breadcrumbs uses the same model binding as the controller. For example:
This makes your code less verbose and more efficient by only loading the page from the database once.

For more details see `Route Model Binding <http://laravel.com/docs/routing#route-model-binding>`_ in the Laravel documentation.
For more details see `Route Model Binding <https://www.laravel.com/docs/5.3/routing#route-model-binding>`_ in the Laravel documentation.


================================================================================
Expand All @@ -116,7 +117,7 @@ Laravel automatically creates route names for resourceful controllers, e.g. ``ph

.. code-block:: php
// app/Http/routes.php
// routes/web.php
Route::resource('photo', 'PhotoController');
.. code-block:: bash
Expand All @@ -137,7 +138,7 @@ Laravel automatically creates route names for resourceful controllers, e.g. ``ph
.. code-block:: php
// app/Http/breadcrumbs.php
// routes/breadcrumbs.php
// Photos
Breadcrumbs::register('photo.index', function($breadcrumbs)
Expand Down Expand Up @@ -167,7 +168,7 @@ Laravel automatically creates route names for resourceful controllers, e.g. ``ph
$breadcrumbs->push('Edit Photo', route('photo.edit', $photo->id));
});
For more details see `RESTful Resource Controllers <http://laravel.com/docs/controllers#restful-resource-controllers>`_ in the Laravel documentation.
For more details see `Resource Controllers <https://www.laravel.com/docs/5.3/controllers#resource-controllers>`_ in the Laravel documentation.


================================================================================
Expand All @@ -178,12 +179,12 @@ To use implicit controllers, you must specify names for each route. For example:

.. code-block:: php
// app/Http/routes.php
// routes/web.php
Route::controller('auth', 'Auth\AuthController', [
'getRegister' => 'auth.register',
'getLogin' => 'auth.login',
]);
(You don't need to provide route names for actions that redirect and never display a view - e.g. most POST views.)

For more details see `Implicit Controllers <http://laravel.com/docs/controllers#implicit-controllers>`_ in the Laravel documentation.
For more details see `Implicit Controllers <https://www.laravel.com/docs/5.1/controllers#implicit-controllers>`_ in the Laravel documentation.
2 changes: 1 addition & 1 deletion docs/start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ And add the facade to ``aliases``:
2. Define your breadcrumbs
================================================================================

Create a file called ``app/Http/breadcrumbs.php`` that looks like this:
Create a file called ``routes/breadcrumbs.php`` that looks like this:

.. code-block:: php
Expand Down
10 changes: 8 additions & 2 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ public function boot()
// This method can be overridden in a child class
public function registerBreadcrumbs()
{
// Load the app breadcrumbs if they're in app/Http/breadcrumbs.php
if (file_exists($file = $this->app['path'].'/Http/breadcrumbs.php'))
// Load the app breadcrumbs if they're in routes/breadcrumbs.php (Laravel 5.3)
if (file_exists($file = $this->app['path.base'].'/routes/breadcrumbs.php'))
{
require $file;
}

// Load the app breadcrumbs if they're in app/Http/breadcrumbs.php (Laravel 5.0-5.2)
elseif (file_exists($file = $this->app['path'].'/Http/breadcrumbs.php'))
{
require $file;
}
Expand Down

0 comments on commit 8e64e8e

Please sign in to comment.