/** * Run the migrations. * * @return void */ public function up() { Schema::table('booths', function ($table) { $table->integer('pv_id'); // 省id }); Schema::table('crowd_fundings', function ($table) { $table->integer('pv_id'); // 省id }); Schema::table('promotion_infos', function ($table) { $table->integer('pv_id'); }); $list = Booth::with(['school'])->get(); foreach ($list as $key => $booth) { $pv_id = $booth->school->t_province; $booth->pv_id = $pv_id; $booth->save(); } $list = CrowdFunding::with(['school'])->get(); foreach ($list as $key => $funding) { $pv_id = $funding->school->t_province; $funding->pv_id = $pv_id; $funding->save(); } $list = PromotionInfo::with(['school'])->get(); foreach ($list as $key => $promo) { $pv_id = $promo->school->t_province; $promo->pv_id = $pv_id; $promo->save(); } }
public function listBooth() { // echo 123;exit; $u_id = Input::get('u_id', ''); $token = Input::get('token'); try { $user = User::chkUserByToken($token, $u_id); $data = Booth::with(['user' => function ($q) { $q->with(['school']); }])->where('u_id', '=', $u_id)->get(); $list = []; foreach ($data as $key => $booth) { $tmp = $booth->showDetail(); $products_count = Product::where('b_id', '=', $booth->b_id)->where('p_status', '=', 1)->count(); $tmp['prodct_count'] = $products_count; $list[] = $tmp; } $re = ['result' => 2000, 'data' => $list, 'info' => '获取我的所有店铺成功']; } catch (Exception $e) { $code = 7001; if ($e->getCode() > 2000) { $code = $e->getCode(); } $re = ['result' => $code, 'data' => [], 'info' => '获取我的所有店铺失败:' . $e->getMessage()]; } return Response::json($re); }
public function listLoans($id) { try { $booth = Booth::with(['fund', 'fund.loans'])->find($id); if (empty($booth)) { throw new Exception("没有找到请求的店铺", 10001); } $income = $booth->fund->getCurrentPeriodIncome(); $boothData = $booth->showDetail(); $fundData = $booth->fund->showDetail(); $data = ['last_income' => $income, 'booth' => $boothData, 'fund' => $fundData]; $re = Tools::reTrue('获取店铺贷款信息成功', $data); } catch (Exception $e) { $re = Tools::reFalse($e->getCode(), '获取店铺信息失败:' . $e->getMessage()); } return Response::json($re); }
public function listBooth() { $owner_id = Input::get('owner', 0); $u_id = Input::get('u_id', 0); try { if (!$u_id) { throw new Exception("请传入有效的用户id", 7001); } $data = Booth::with(['user'])->where('u_id', '=', $owner_id)->where('b_status', '=', 1)->get(); $list = []; foreach ($data as $key => $booth) { $tmp = $booth->showDetail(); $products_count = Product::where('b_id', '=', $booth->b_id)->where('p_status', '=', 1)->count(); $tmp['prodct_count'] = $products_count; $chk_follow = BoothFollow::where('u_id', '=', $u_id)->where('b_id', '=', $booth->b_id)->first(); if (empty($chk_follow)) { $tmp['is_follow'] = 0; } else { $tmp['is_follow'] = 1; } $list[] = $tmp; } $re = Tools::reTrue('获取我的所有店铺成功', $list); } catch (Exception $e) { $re = Tools::reFalse($e->getCode(), '获取他的所有店铺失败:' . $e->getMessage()); } return Response::json($re); }