예제 #1
0
 public function extractData()
 {
     $gifts = Gift::all();
     //礼品
     $topics = Topic::all();
     // 话题
     $gift_posters = GiftPoster::all();
     //礼品海报
     $gift_photo_intros = GiftPhotoIntro::all();
     //图文介绍
     // fwrite(fopen(app_path().'\storage\mysq.txt', 'w'), 'man');
     file_put_contents(app_path() . '/storage/gifts.txt', json_encode($gifts));
     file_put_contents(app_path() . '/storage/topics.txt', json_encode($topics));
     file_put_contents(app_path() . '/storage/gift_posters.txt', json_encode($gift_posters));
     file_put_contents(app_path() . '/storage/gift_photo_intros.txt', json_encode($gift_photo_intros));
     return 0;
 }
예제 #2
0
 public function selectByLabel()
 {
     $inputs = array('char_id' => Input::get('_char'), 'scene_id' => Input::get('scene'), 'object_id' => Input::get('object'), 'price_id' => Input::get('price'));
     // dd($inputs['object_id']);
     $per_page = Input::get('per_page');
     $page = Input::get('page');
     $inputs = array_filter($inputs);
     // dd(count($inputs));
     $query = null;
     // dd($inputs['price_id']);
     foreach ($inputs as $key => $value) {
         if ($query != null) {
             $query = $query->where($key, $value);
         } else {
             $query = Gift::where($key, $value);
         }
     }
     if ($query == null) {
         // dd(count($gifts));
         //标签没有的情况
         $gifts = Gift::all();
         $total = ceil(count($gifts) / $per_page);
         $gifts = StaticController::page($per_page, $page, $gifts);
         $gifts = $this->addGiftPhotoAndFocus($gifts);
         return Response::json(array('errCode' => 0, 'message' => '没有筛选礼品,返回全部1', 'gifts' => $gifts, 'total' => $total));
     }
     $gifts = $query->get();
     if (count($gifts) == 0) {
         $gifts = Gift::all();
         $total = ceil(count($gifts) / $per_page);
         $gifts = StaticController::page($per_page, $page, $gifts);
         $gifts = $this->addGiftPhotoAndFocus($gifts);
         return Response::json(array('errCode' => 0, 'message' => '没有筛选礼品,返回全部2', 'gifts' => $gifts, 'total' => $total));
     }
     $total = ceil(count($gifts) / $per_page);
     $gifts = StaticController::page($per_page, $page, $gifts);
     $gifts = $this->addGiftPhotoAndFocus($gifts);
     return Response::json(array('errCode' => 0, 'message' => '返回搜索数据', 'gifts' => $gifts, 'total' => $total));
 }