コード例 #1
0
 public function cachecate()
 {
     $data = \App\Categories::select(array('id', 'name'))->whereRaw("cid_parent=0 AND status='1'")->orderBy("id", "ASC")->get();
     $j = array();
     foreach ($data as $key => $value) {
         $j[] = array($value['id'], IndexController::toAlias2($value['name']));
     }
     echo json_encode($j);
 }
コード例 #2
0
ファイル: CategoriesController.php プロジェクト: jither7/vcar
    /**
     * @return mixed
     */
    public function data()
    {
        $categories = Categories::select('id', 'name', 'description', 'slug')->orderBy('id', 'desc');
        return Datatables::of($categories)->editColumn('name', '
				<a href="#"><b>{{$name}}</b></a>
				<div class="row-actions hide">
					<a href="{{{ URL::to(\'admin/categories/edit/\' . $id . \'/\') }}}">Edit</a>
					|
					<a class="delete-tag" href="{{ URL::to(\'admin/categories/delete/\' . $id .\'/\') }}"
						onclick=" return confirm(\'Are you want to delete\')">Delete</a>
					|
					<a href="#">View</a>
				</div>
			')->editColumn('id', '<input id="cb-select-all-1" type="checkbox" data="{{$id}}">')->make();
    }
コード例 #3
0
 /**
  * Display a listing of the resource to the categories
  *
  * @return Response
  */
 public function list_product_cate_parent($id, $limit)
 {
     $c = md5($id . $limit);
     return Cache::remember("list_product_cate_parent_" . $c, 5, function () use($id, $limit) {
         $child = Categories::select("id")->whereRaw("cid_parent={$id} AND status='1'")->remember(120)->get()->toArray();
         $x = array();
         foreach ($child as $key => $value) {
             $x[] = $value['id'];
         }
         $x = implode(",", $x);
         if (!empty($x)) {
             return Product::select(array(DB::raw("check_coupon(pro_product.id,pro_product.cid_cate,1) AS discountcoupon"), DB::raw("check_coupon(pro_product.id,pro_product.cid_cate,2) AS coupons"), DB::raw("get_review(pro_product.id,1) AS rating"), DB::raw("get_review(pro_product.id,2) AS countrating"), DB::raw("get_price(pro_supplier_product.id,pro_supplier_product.discount) AS discount"), DB::raw("get_sale_price(pro_supplier_product.id,pro_supplier_product.saleprice) AS saleprice"), "pro_product.id", "pro_product.id AS myid", "pro_product.name", "pro_product.isprice", "pro_supplier_product.id AS cid_res", "pro_supplier_product.cid_supplier"))->whereRaw("pro_product.cid_cate IN ({$x})   AND pro_supplier_product.status='1' AND pro_product.status='1' AND pro_product.is_status_cate='1' AND pro_product.is_status_series='1' AND pro_product.is_home='1' ")->join("pro_supplier_product", function ($join) {
                 $join->on("pro_product.id", "=", "pro_supplier_product.cid_product");
             })->orderBy("pro_supplier_product.date_mod", "DESC")->limit($limit)->get()->toJson();
         }
     });
 }