12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?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|array',
- ]);
- if ($validator->fails()) {
- return $this->jsonError($validator->errors()->first());
- }
- $shop = Shop::whereIn('shop_id',$data['ids'])->where('status',0)->select('shop_id','shop_name')->get();
- if($shop){
- return $this->jsonSuccess($shop);
- }else{
- return $this->jsonError('失败未找到');
- }
- }
- }
|