<?php namespace App\Http\Controllers; use App\Model\PaymentDaysModel; use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller; class ApiController extends Controller { public function Entrance(Request $request, $id ){ $this->$id($request, $id); } private function Export($errcode=0,$errmsg='成功',$data=''){ if(is_array($errcode)){ ErrorLog($errcode[0],$errcode[1]); echo json_encode(['errcode'=>$errcode[0],'errmsg'=>$errcode[1],'data'=>!empty($errcode[2])?$errcode[2]:'']); exit(); }else{ ErrorLog($errcode,$errmsg); echo json_encode(['errcode'=>$errcode,'errmsg'=>$errmsg,'data'=>$data]); exit(); } } private function ExportLayui($errcode=0,$errmsg=0,$data=[],$count=0){ if(is_array($errcode)){ ErrorLog($errcode[0],$errcode[1]); echo json_encode(['code'=>$errcode[0],'msg'=>$errcode[1],'data'=>$errcode[2],'count'=>$errcode[3]]); }else{ ErrorLog($errcode,$errmsg); echo json_encode(['code'=>$errcode,'msg'=>$errmsg,'data'=>$data,'count'=>$count]); } exit(); } private function ApiPaymentDaysList(){ $Model=new PaymentDaysModel(); $this->ExportLayui($Model->ApiPaymentDaysList()); } private function ApiAuthPaymentDays($request){ $Model=new PaymentDaysModel(); $this->Export($Model->ApiAuthPaymentDays($request->user->userId)); } }