有没有办法在控制器中访问ViewComposer变量

时间:2017-07-18 08:42:57

标签: laravel

我有以下作曲家。我希望在我的应用程序中访问$myId控制器的每个操作。我该如何实现这一目标?任何帮助都会很棒。

class DistributorComposer {

    /**
     * Create a new Category composer.
     *
     * @param  $menuStr
     * @return void
     */
    // Global Variables for menu
    var $menuStr = '';

    public function __construct()
    {
    }

    public function compose(View $view) {
        //$data['language'] = FrontendController::getDistributorInfo();
        $view->with('myId',Input::get('d_id'));
    }
}

1 个答案:

答案 0 :(得分:0)

在分配 - \App::instance('myId', $myId);

时使用此功能

这是在检索 - $myId = \App('myId');