コード例 #1
0
ファイル: GoodsController.php プロジェクト: Lazybin/huisa
 public function show()
 {
     $data['categories'] = Category::where('pid', 0)->get();
     $data['activity_classification'] = ActivityClassification::all();
     $data['free_post'] = FreePost::all();
     return view('admin.goods.index', $data);
 }
コード例 #2
0
 /**
  *
  * @SWG\Api(
  *   path="/activity_page",
  *   description="约惠主页(有更新20160308)",
  *   @SWG\Operation(
  *     method="GET", summary="获得约惠主页内容", notes="获得约惠主页内容",
  *     type="ActivityPage",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="user_id",
  *         description="用户id",
  *         paramType="query",
  *         required=false,
  *         allowMultiple=false,
  *         type="integer",
  *         defaultValue=-1
  *     )
  *   )
  * )
  */
 public function index(Request $request)
 {
     $user_id = $request->input('user_id', -1);
     $response = new BaseResponse();
     $ret = (object) null;
     $banners = Banner::where('banner_position', 1)->get();
     $ret->banners = $banners;
     //分类
     $activityClassification = ActivityClassification::all();
     $ret->activityClassification = $activityClassification;
     //包邮
     $freePost = FreePost::all();
     $ret->freePost = $freePost;
     //爆品
     $conversionGoods = ConversionGoods::all();
     //$conversionGoods=$conversionGoods->toArray();
     foreach ($conversionGoods as &$v) {
         $v->has_collection = 0;
         if ($user_id != -1) {
             $collection = Collection::where('user_id', $user_id)->where('type', 0)->where('item_id', $v->goods_id)->first();
             if ($collection != null) {
                 $v->has_collection = 1;
             }
         }
     }
     $ret->conversionGoods = $conversionGoods;
     $response->Data = $ret;
     return $response->toJson();
 }
コード例 #3
0
 public function getActivityClassificationsAttribute()
 {
     $activityClassification = ActivityClassification::find($this->activity_classification_id);
     if ($activityClassification == null) {
         return '';
     }
     return $activityClassification->toArray();
 }
コード例 #4
0
 /**
  *
  * @SWG\Api(
  *   path="/activity_classifications",
  *   description="活动",
  *   @SWG\Operation(
  *     method="GET", summary="获得活动分类列表", notes="获得活动分类列表",
  *     type="ActivityClassification",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="PageNum",
  *         description="分页开始位置",
  *         paramType="query",
  *         required=false,
  *         allowMultiple=false,
  *         type="integer",
  *         defaultValue=1
  *     ),@SWG\Parameter(
  *         name="PerPage",
  *         description="取得长度",
  *         paramType="query",
  *         required=false,
  *         allowMultiple=false,
  *         type="integer",
  *         defaultValue=10
  *     )
  *
  *   )
  * )
  */
 public function index(Request $request)
 {
     //
     $start = $request->input('PageNum', 0);
     $length = $request->input('PerPage', 5);
     $start = ($start - 1) * $length;
     $response = new BaseResponse();
     $home = ActivityClassification::skip($start)->take($length)->orderBy('sort')->orderBy('id', 'desc');
     $response->rows = $home->get();
     $response->total = ActivityClassification::count();
     return $response->toJson();
 }
コード例 #5
0
 public function delete($id)
 {
     ActivityClassification::find($id)->delete();
     $ret['meta']['code'] = 1;
     echo json_encode($ret);
 }