2017 © Pedro Peláez
 

library fox-tail

A Laravel package to manage routes user accessed.

image

sukohi/fox-tail

A Laravel package to manage routes user accessed.

  • Thursday, June 15, 2017
  • by Sukohi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

FoxTail

A Laravel package to manage routes user accessed. (L5.4+), (*1)

Installation

Execute the next command., (*2)

composer require sukohi/fox-tail:1.*

Set the service provider in config/app.php., (*3)

'providers' => [
    ...Others...,
    Sukohi\FoxTail\FoxTailServiceProvider::class,
]

Also alias, (*4)

'aliases' => [
    ...Others...,
    'FoxTail'   => Sukohi\FoxTail\Facades\FoxTail::class,
]

Then execute the next commands., (*5)

php artisan vendor:publish

Now you have config/fox_tail.php., (*6)

Definition

  • Tail: A set of data a user will access. It contains name(route name or uri), method, url, full_url and parameters., (*7)

  • Story: A set of Tails user could access., (*8)

Preparation

(Middleware), (*9)

You need to set FoxTailMiddleware in \App\Http\Kernel.php like so., (*10)

protected $routeMiddleware = [
    ...Others...,
    'fox_tail' => \Sukohi\FoxTail\Middleware\FoxTailMiddleware::class
];

And also in routes/web.php, (*11)

Route::middleware(['fox_tail'])->group(function(){

    Route::get('/my/page/1', 'HomeController@mypage_1')->name('my-page-1');
    Route::get('/my/page/2', 'HomeController@mypage_2')->name('my-page-2');
    Route::get('/my/page/3', 'HomeController@mypage_3')->name('my-page-3');

});

In this case, FoxTail watches /my/page/1, /my/page/2 and /my/page/3.
Then, it will keep Tail in session., (*12)

(Config)
In config/fox_tail.php, you can set Story which means user's access history.
See the file for the details., (*13)

Usage

Check if Story you set in the config file matches., (*14)

$story_name = 'how_much';

if(\FoxTail::isStory($story_name)) {

    echo 'Match!';

}

Get all Tails, (*15)

$tails = \FoxTail::getTails();   // Laravel Collection

Get a Tail, (*16)

$tail = \FoxTail::getTail($tail_name);
echo $tail->method;
echo $tail->url;
echo $tail->full_url;
print_r($tail->parameters); // Array

// or

echo \FoxTail::getMethod($tail_name);
echo \FoxTail::getUrl($tail_name);
echo \FoxTail::getFullUrl($tail_name);
print_r(\FoxTail::getParameters($tail_name));   // Array

Check if FoxTail has a Tail or not, (*17)

$tail_name = 'about_us';

if(\FoxTail::has($tail_name)) {

    echo 'Has it!';

    $tail = \FoxTail::getTail($tail_name);

}

Check if the previous Tail name, (*18)

$tail_name = 'about_us';

if(\FoxTail::isPrevious($tail_name)) {

    echo 'That is right!';

}

Get Tail and Tail name by step, (*19)

echo \FoxTail::getTailNameByStep();    // Current tail
echo \FoxTail::getTailNameByStep(1);    // The previous tail tail

print_r(\FoxTail::getTailByStep());    // Current tail by step
print_r(\FoxTail::getTailByStep(1));    // The previous tail by step

License

This package is licensed under the MIT License., (*20)

Copyright 2017 Sukohi Kuhoh, (*21)

The Versions

15/06 2017

1.0.x-dev

1.0.9999999.9999999-dev

A Laravel package to manage routes user accessed.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

15/06 2017

dev-master

9999999-dev

A Laravel package to manage routes user accessed.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

15/06 2017

1.0.2

1.0.2.0

A Laravel package to manage routes user accessed.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

15/06 2017

1.0.1

1.0.1.0

A Laravel package to manage routes user accessed.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

15/06 2017

1.0.0

1.0.0.0

A Laravel package to manage routes user accessed.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi