1.控制器中
$list = Userlawsbook::where($where)->with('lawsbook')->paginate(7); // 此处查出来为数组对象
dump[0]['lawsbook']; // 可直接打印出第一个关联的对象
2.模型中
public function lawsbook()
{
return $this->belongsTo('appcommonmodelchinaLawsbook', 'china_lawsbook_id', 'id', [], 'LEFT')->setEagerlyType(0); // 关联模型
}
3.模板中输出
{volist name="list" id="v"}
<li>
<span class="time">{:date('Y-m-d H:i:s',$v['createtime'])}</span>
<p class="henadP">{$v['lawsbook']['title']}</p> <!--关联中表中的title-->
<a href="#">下载</a>
</li>
{/volist}