Laravel 5

遍历数组@foreach($brand as $v)
  <a href='/brandss/seeshops?id={{$v->id}}'><img src="/public{{$v->image}}" style="height: 300px;width: 300px"></a></img>
  <a href="/brandss/seeshops?id={{$v->id}}">{{$v->brandName}}</a>
@endforeach

============

 

============

数据库查询:

$cates = DB::table('tp_article')->where('odds','=', $pid)->get();

public static function getCatesByDiGui($pid)
{
//获取分类
// return 'sss';
$cates = DB::table('tp_article')->where('odds','=', $pid)->get();
//遍历分类信息
var_dump($cates);
exit;
// $cates = DB::table('tp_article')->where('odds','=', '$pid')->get();
$sub_cate = [];
foreach($cates as $k=>$v) {
$v->sub_cate = self::getCatesByDiGui($v->id);
$sub_cate[] = $v;
}
return $sub_cate;
}

 

posted @ 2018-02-07 11:07  林间有风-邓  阅读(113)  评论(0编辑  收藏  举报