update 1.0.8.0
Commits for version update
This commit is contained in:
@@ -45,9 +45,9 @@ The ``$data`` array's entries will be merged into the breadcrumb as properties,
|
||||
|
||||
.. code-block:: html+php
|
||||
|
||||
<li><a href="{{{ $breadcrumb->url }}}">
|
||||
<img src="/images/icons/{{{ $breadcrumb->icon }}}">
|
||||
{{{ $breadcrumb->title }}}
|
||||
<li><a href="{{ $breadcrumb->url }}">
|
||||
<img src="/images/icons/{{ $breadcrumb->icon }}">
|
||||
{{ $breadcrumb->title }}
|
||||
</a></li>
|
||||
|
||||
Do not use the following keys in your data array, as they will be overwritten: ``title``, ``url``, ``first``, ``last``.
|
||||
@@ -57,7 +57,38 @@ 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:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
class MyServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register() {}
|
||||
|
||||
public function boot()
|
||||
{
|
||||
if (class_exists('Breadcrumbs'))
|
||||
require __DIR__ . '/breadcrumbs.php';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.. _switching-views:
|
||||
@@ -126,8 +157,8 @@ If you want to pass an array of parameters instead you can use these methods:
|
||||
By default an exception will be thrown if the breadcrumb doesn't exist, so you know to add it. If you want suppress this you can call the following methods instead:
|
||||
|
||||
- ``Breadcrumbs::renderIfExists()`` (returns an empty string)
|
||||
- ``Breadcrumbs::renderArrayIfExists()`` (returns an empty string)
|
||||
- ``Breadcrumbs::renderIfExistsArray()`` (returns an empty string) (was ``renderArrayIfExists`` before 3.0.0)
|
||||
- ``Breadcrumbs::generateIfExists()`` (returns an empty array)
|
||||
- ``Breadcrumbs::generateArrayIfExists()`` (returns an empty array)
|
||||
- ``Breadcrumbs::generateIfExistsArray()`` (returns an empty array) (was ``generateArrayIfExists`` before 3.0.0)
|
||||
|
||||
Alternatively you can call ``Breadcrumbs::exists('name')``, which returns a boolean.
|
||||
|
@@ -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)`
|
||||
================================================================================
|
||||
|
@@ -2,11 +2,13 @@
|
||||
Contributing
|
||||
################################################################################
|
||||
|
||||
.. This text is also in ../CONTRIBUTING.rst
|
||||
.. NOTE: This text is also in ../README.rst
|
||||
|
||||
If you want to submit a **bug fix**, make your changes in a new branch, based on the ``develop`` branch, then simply open a `pull request <https://github.com/davejamesmiller/laravel-breadcrumbs/pulls>`_ on GitHub. (The information below may help you to get started if you've not done this before.)
|
||||
If you want to submit a **bug fix**, please make your changes in a new branch, then open a `pull request <https://github.com/davejamesmiller/laravel-breadcrumbs/pulls>`_. (The `Contributing page of the docs <http://laravel-breadcrumbs.davejamesmiller.com/en/latest/contributing.html>`_ may help you to get started if you've not done this before.)
|
||||
|
||||
If you want to submit a **new feature**, it's usually best to open an `issue <https://github.com/davejamesmiller/laravel-breadcrumbs/issues>`_ to discuss the idea first -- to make sure it will be accepted before spending too much time on it. (Of course you can go ahead and develop it first if you prefer!) Please be sure to update the documentation as well.
|
||||
If you want to submit a **new feature**, it's usually best to open an `issue <https://github.com/davejamesmiller/laravel-breadcrumbs/issues>`_ to discuss the idea first -- to make sure it will be accepted before spending too much time on it. (Of course you can go ahead and develop it first if you prefer!) Please be sure to include unit tests and update the documentation as well.
|
||||
|
||||
If you have any suggestions for improving the **documentation** -- especially if anything is unclear to you and could be explained better -- please let me know. (Or just edit it yourself and make a pull request.)
|
||||
|
||||
.. only:: html
|
||||
|
||||
@@ -28,7 +30,7 @@ If you've already got it installed, delete it from the ``vendor/`` directory and
|
||||
$ rm -rf vendor/davejamesmiller/laravel-breadcrumbs
|
||||
$ composer install --prefer-source
|
||||
$ cd vendor/davejamesmiller/laravel-breadcrumbs
|
||||
$ git checkout -t origin/develop
|
||||
$ git checkout -t origin/master
|
||||
$ git checkout -b YOUR_BRANCH
|
||||
# Make changes and commit them
|
||||
$ git remote add YOUR_USERNAME git@github.com:YOUR_USERNAME/laravel-breadcrumbs
|
||||
|
@@ -30,7 +30,7 @@ For generating the URL, you can use any of the standard Laravel URL-generation m
|
||||
|
||||
- ``url('path/to/route')`` (``URL::to()``)
|
||||
- ``secure_url('path/to/route')``
|
||||
- ``route('routename')`` (``URL::route()``)
|
||||
- ``route('routename')`` or ``route('routename', 'param')`` or ``route('routename', ['param1', 'param2'])`` (``URL::route()``)
|
||||
- ``action('controller@action')`` (``URL::action()``)
|
||||
- Or just pass a string URL (``'http://www.example.com/'``)
|
||||
|
||||
@@ -64,6 +64,8 @@ This is another static page, but this has a parent link before it:
|
||||
$breadcrumbs->push('Blog', route('blog'));
|
||||
});
|
||||
|
||||
It works by calling the closure for the ``home`` breadcrumb defined above.
|
||||
|
||||
It would be rendered like this:
|
||||
|
||||
.. raw:: html
|
||||
@@ -78,6 +80,8 @@ It would be rendered like this:
|
||||
|
||||
Home > Blog
|
||||
|
||||
Note that the default template does not create a link for the last breadcrumb (the one for the current page), even when a URL is specified. You can override this by creating your own template - see :doc:`templates` for more details.
|
||||
|
||||
|
||||
================================================================================
|
||||
Dynamic titles and links
|
||||
|
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]);
|
||||
@@ -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');
|
||||
@@ -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.
|
||||
|
||||
|
||||
================================================================================
|
||||
@@ -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
|
||||
@@ -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)
|
||||
@@ -167,29 +168,23 @@ 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.
|
||||
|
||||
|
||||
================================================================================
|
||||
Implicit controllers
|
||||
================================================================================
|
||||
|
||||
Laravel doesn't appear to support named routes in implicit controllers (tested on Laravel 5.0.2), so you will not be able to use them with route-bound breadcrumbs. For example:
|
||||
To use implicit controllers, you must specify names for each route. For example:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
// app/Http/routes.php
|
||||
Route::controller('users', 'UserController');
|
||||
// routes/web.php
|
||||
Route::controller('auth', 'Auth\AuthController', [
|
||||
'getRegister' => 'auth.register',
|
||||
'getLogin' => 'auth.login',
|
||||
]);
|
||||
|
||||
.. code-block:: bash
|
||||
(You don't need to provide route names for actions that redirect and never display a view - e.g. most POST views.)
|
||||
|
||||
$ php artisan route:list
|
||||
+----------+-----------------------------------------+-----------+------------------------------+
|
||||
| Method | URI | Name | Action |
|
||||
+----------+-----------------------------------------+-----------+------------------------------+
|
||||
| GET|HEAD | users | | UserController@getIndex |
|
||||
| GET|HEAD | users/index/{one?}/{two?}/{three?}... | | UserController@getIndex |
|
||||
| POST | users/profile/{one?}/{two?}/{three?}... | | UserController@postProfile |
|
||||
+----------+-----------------------------------------+-----------+------------------------------+
|
||||
|
||||
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.
|
||||
|
@@ -40,7 +40,7 @@ Add the service provider to ``providers``:
|
||||
|
||||
'providers' => [
|
||||
// ...
|
||||
'DaveJamesMiller\Breadcrumbs\ServiceProvider',
|
||||
DaveJamesMiller\Breadcrumbs\ServiceProvider::class,
|
||||
],
|
||||
|
||||
And add the facade to ``aliases``:
|
||||
@@ -49,7 +49,7 @@ And add the facade to ``aliases``:
|
||||
|
||||
'aliases' => [
|
||||
// ...
|
||||
'Breadcrumbs' => 'DaveJamesMiller\Breadcrumbs\Facade',
|
||||
'Breadcrumbs' => DaveJamesMiller\Breadcrumbs\Facade::class,
|
||||
],
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -106,7 +106,7 @@ See the :doc:`defining` section for more details.
|
||||
3. Choose a template
|
||||
================================================================================
|
||||
|
||||
By default a `Bootstrap <http://getbootstrap.com/components/#breadcrumbs>`_-compatible unordered list will be rendered, so if you're using Bootstrap 3 you can skip this step.
|
||||
By default a `Bootstrap <http://getbootstrap.com/components/#breadcrumbs>`_-compatible ordered list will be rendered, so if you're using Bootstrap 3 you can skip this step.
|
||||
|
||||
First initialise the config file by running this command:
|
||||
|
||||
|
@@ -20,9 +20,9 @@ To customise the HTML, create your own view file (e.g. ``resources/views/_partia
|
||||
<ul class="breadcrumb">
|
||||
@foreach ($breadcrumbs as $breadcrumb)
|
||||
@if (!$breadcrumb->last)
|
||||
<li><a href="{{{ $breadcrumb->url }}}">{{{ $breadcrumb->title }}}</a></li>
|
||||
<li><a href="{{ $breadcrumb->url }}">{{ $breadcrumb->title }}</a></li>
|
||||
@else
|
||||
<li class="active">{{{ $breadcrumb->title }}}</li>
|
||||
<li class="active">{{ $breadcrumb->title }}</li>
|
||||
@endif
|
||||
@endforeach
|
||||
</ul>
|
||||
@@ -41,11 +41,11 @@ The view will receive an array called ``$breadcrumbs``.
|
||||
|
||||
Each breadcrumb is an object with the following keys:
|
||||
|
||||
- ``title`` - The title you set above
|
||||
- ``url`` - The URL you set above
|
||||
- ``title`` - The breadcrumb title (see :doc:`defining`)
|
||||
- ``url`` - The breadcrumb URL (see :doc:`defining`), or ``null`` if none was given
|
||||
- ``first`` - ``true`` for the first breadcrumb (top level), ``false`` otherwise
|
||||
- ``last`` - ``true`` for the last breadcrumb (current page), ``false`` otherwise
|
||||
- Additional keys for each item in ``$data`` (see :ref:`custom-data`)
|
||||
- Plus additional keys for each item in ``$data`` (see :ref:`custom-data`)
|
||||
|
||||
|
||||
================================================================================
|
||||
@@ -56,4 +56,5 @@ Then update your config file (``config/breadcrumbs.php``) with the custom view n
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
// resources/views/_partials/breadcrumbs.blade.php
|
||||
'view' => '_partials/breadcrumbs',
|
||||
|
Reference in New Issue
Block a user