1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?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($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());
- }
- $shop = Shop::whereIn('shop_id',explode(',',$data['ids']))->where('status',0)->pluck('shop_name','shop_id');
- if($shop){
- return $this->jsonSuccess($shop);
- }else{
- return $this->jsonError('失败未找到');
- }
- }
- }
|