php - Laravel 5 handle return from controller -
i have application has many views use need inject code specific sections of view. in previous application had used root controller , used special functions kind of changes normal workflow of creating laravel application way.
basically have create function
public function create() { return view('something'); }
and want add specific section, in view , add data needed call view. want in controller since function returning view show same thing in case want simplify bit.
i tried looking not find post processing on controller function, there that? here example.
public function beforerender($instance) { if ($instance instanceof view) { $instance->getfactory()->inject('context-menu', $somedata); } return $instance; }
the beforerender function run after create function in controller , alter return, allowing special return view.
so question if there in laravel 5 (or similar) , how might it. in previous app had remade how laravel handled controllers want avoid doing time.
if i'm not mistaken, feature implemented in laravel 5.1. may grab dev version or wait until release out.
service injection in laravel docs:
@inject('metrics', 'app\services\metricsservice') <div> monthly revenue: {{ $metrics->monthlyrevenue() }}. </div>
you may check code composers well. approach bit different, keeping views spick , span:
public function compose(view $view) { $view->with('count', $this->users->count()); }
Comments
Post a Comment