php - How to inject a custom property to Illuminate Routing Route class -


in other words, how override class add custom property route class. instance suppose following in routes/web.php:

route::get('/post', 'postcontroller@index')->description('this posts list')

the above code generate undefined method error:

call undefined method illuminate\routing\route::description()

i have tried define in providers/routeserviceprovider.php following:

<?php  namespace app\providers;  use illuminate\support\facades\route; use illuminate\foundation\support\providers\routeserviceprovider serviceprovider;  class routeserviceprovider extends serviceprovider {     /**      * namespace applied controller routes.      *      * in addition, set url generator's root namespace.      *      * @var string      */     protected $namespace = 'app\http\controllers';      public $description = null;      /**      * define route model bindings, pattern filters, etc.      *      * @return void      */     public function boot()....       .....      public function description($txt = null)     {         $this->description = $txt;     } } 

also same undefined method error coming.

i tried answer of how extend illuminate\routing\route in laravel? following:

//in appserveiceprovider.php public function register()     {         if ($this->app->environment() !== 'production') {             $this->app->register(\barryvdh\laravelidehelper\idehelperserviceprovider::class);         }          $this->app->bind('illuminate\routing\route', \app\http\helpers\foxroute::class);     } 

the above solution seems not feel foxroute before defining @ app\http\helpers there no error generated while undefined method error exist following foxroute class:

<?php   namespace app\http\helpers; class foxroute extends illuminate\routing\route {     public function __construct($methods, $uri, $action) {         parent::__construct($methods, $uri, $action);     } } 

i want define such method , make return property description in route object defaults() !


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -