Created
September 8, 2016 02:49
-
-
Save jarektkaczyk/09c2540564ccbe31b2540a03687125b0 to your computer and use it in GitHub Desktop.
Handy helper for working with route list in tinker [Laravel]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Easily get route list in tinker | |
>>> app('RouteList')->setOption('method', 'PUT')->getRoutes() | |
>>> app('RouteList')->getRoutes()->where('name', 'website.login') | |
class RouteList extends \Illuminate\Foundation\Console\RouteListCommand | |
{ | |
/** @var array */ | |
public $options; | |
protected $laravel; | |
public function __construct(Illuminate\Routing\Router $router) | |
{ | |
parent::__construct($router); | |
$this->setLaravel(app()); | |
} | |
public function getRoutes() | |
{ | |
return collect(parent::getRoutes())->values(); | |
} | |
public function setOption($key, $value) | |
{ | |
$this->options[$key] = $value; | |
return $this; | |
} | |
public function option($key=null) | |
{ | |
return data_get($this->options, $key); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment