Ejemplo n.º 1
0
 public function getIndex(Request $request)
 {
     $page = $request->input('page');
     $type = $request->input('type');
     $code = $request->input('code');
     $offset = 20;
     $query = Advertise::where('id', '>', 0);
     if (!empty($type)) {
         $query->where('type', '=', $type);
     }
     if (!empty($code)) {
         $query->where('code', '=', $code);
     }
     $count = $query->count();
     $pages = ceil($count / $offset);
     $page = !empty($page) ? $page > $pages ? $pages : $page < 1 ? 1 : $page : 1;
     $ads = $query->skip(($page - 1) * $offset)->take($offset)->get();
     $data = ['pageName' => '广告位管理', 'current_page' => $page, 'pages' => $pages, 'ads' => $ads, 'route' => $this->route];
     return view('admin/advertise_board', $data);
 }
Ejemplo n.º 2
0
	/**
	 * Show the application dashboard to the user.
	 *
	 * @return Response
	 */
	public function index(Request $request)
	{
    $goodDatas = Good::orderBy('id', 'desc')->get();

    $goods = array();

    $banners = Advertise::where('type', '=', 'index_banner')
      
      ->where('active', '=', 1)
      
      ->orderBy('seq', 'asc')
      
      ->get();

    foreach ($goodDatas as $good) {

      $gInfo = GoodAttribsInfo::where('gid', '=', $good->id)

        ->where('acode', '=', 'price')

        ->first();

      $good->price = $gInfo->value;

      array_push($goods, $good);

    }

    $homeGoodsDisplay = array();

    foreach ($goods as $key => $good) {

      if (0 == $key % 2) {

        $homeGoodsDisplay[$key / 2] = array();

      }

      $homeGoodsDisplay[$key / 2][] = $good;

    }

    /////
    $goods = Good::orderBy('id', 'desc')->get();

    $gid = empty($request->input('gid')) ? $goods[0]->id : $request->input('gid');

    $goodInfos = array();

    foreach ($goods as $key => $good) {

      $goodInfo = GoodAttribsInfo::where('gid', '=', $good->id)

        ->where('acode', '=', 'price')
      
        ->first();

      $goodInfos[$key] = $goodInfo;

    }
    /////

    return view('home', array(
    
      'goods' => $goods,

      'banners' => $banners,

      'home' => 1,

      'gid' => $gid,

      'active' => 'active',

      'goodInfos' => $goodInfos,

      'is_select' => true,

      'wTitle' => '51临牌网-您身边的车辆临时牌照专家'
    
    ));

	}