123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019-05-06
- * Time: 16:01
- */
- namespace App\Http\Controllers\V1;
- use App\Shop;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Validator;
- class ShopController extends Controller {
- /**
- * @param Request $request
- * @return array
- * 获取商户详情
- */
- public function getShop(Request $request){
- $data = $request->only('id');
- $validator = Validator::make($data, [
- 'id' => 'required|integer',
- ]);
- if ($validator->fails()) {
- return $this->jsonError($validator->errors()->first());
- }
- $res['data'] = Shop::where('shop_id',$data['id'])->first();
- if($res){
- return $this->jsonSuccess(['data'=>$res]);
- }else{
- return $this->jsonError('获取失败');
- }
- }
- /**
- * @param Request $request
- * @return array
- * 根据ids 获取商户
- */
- public function getShopList(Request $request){
- $data = $request->only('ids');
- $validator = Validator::make($data, [
- 'ids' => 'required|string',
- ]);
- if ($validator->fails()) {
- return $this->jsonError($validator->errors()->first());
- }
- $ids = explode(",", $request['ids']);
- $data = [];
- foreach ($ids as $v){
- $shop = Shop::where('shop_id',$v)->first();
- if($shop){
- $data[][$shop->shop_id] =$shop->shop_name;
- }else{
- return $this->jsonError('失败 shop_id '.$v.'未找到');
- }
- }
- return $this->jsonSuccess($data);
- }
- }
|