我有一个名为head的局部视图,我在索引视图之前呈现此部分,我从模型获取客户端信息,然后我想将此客户端模型传递给头部分,但我不能。 这是我的代码:
class IndexController extends ControllerBase
{
public function initialize()
{
$this->tag->setTitle($this->lang('index')->_('title'));
$this->view->setTemplateAfter('header');
$this->view->setTemplateBefore('footer');
}
public function indexAction()
{
$this->view->t = $this->lang('index');
$this->view->client = $this->getClient();
}
这是我的基本控制器
class ControllerBase extends Controller
{
public function getClient()
{
$auth = $this->session->get('auth');
return Client::findFirst([
"client_id = :client_id:",
'bind' => [
'client_number' => $auth['client_id']
]
]);
}
如何将此客户端模型传递给部分?