mpaleo/view-tags

Simple way to tag your Laravel views
352 4
Install
composer require mpaleo/view-tags
Latest Version:v1.0.0
PHP:>=5.5.9
License:MIT
Last Updated:Mar 5, 2016
Links: GitHub  ·  Packagist
Maintainer: mpaleo

Laravel view tags

Software License

Installation

  1. Add the package to your composer.json

    ...
    "mpaleo/view-tags": "~1.0",
    ...
    
  2. Update

    composer update
    
  3. Add the service provider to the providers array in {laravel-root}\config\app.php

    ...
    ViewTags\ViewTagsServiceProvider::class,
    ...
    
  4. Add the alias in {laravel-root}\config\app.php

    ...
    'ViewTags' => ViewTags\ViewTags::class,
    ...
    

Usage

Tag views

ViewTags::tag('viewOne', 'someTag');
ViewTags::tag('viewTwo', 'someTag');
ViewTags::tag('viewThree', ['someTag', 'anotherTag']);

Get tagged views

ViewTags::taggedWith('someTag');
/* Output:
 * array(3) {
 *   [0] => "viewOne"
 *   [1] => "viewTwo"
 *   [2] => "viewThree"
 * }
 */
 
ViewTags::taggedWith('anotherTag');
/* Output:
 * array(1) {
 *   [0] => "viewThree"
 * }
 */

License

The view tags package is licensed under the MIT license