input(); if ($data != null ) { $today=Carbon::now()->subDays(15); $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) { return $query->with('user'); }])->orderBy('id','DESC'); if ($request->input('waybill_number')){ $waybills =$waybills->where('waybill_number','like','%'.$request->input('waybill_number').'%')->where('created_at','>',$today->format('Y-m-d')); } if ($request->input('carrier_bill')){ $waybills=$waybills->where('carrier_bill','like','%'.$request->input('carrier_bill').'%')->where('created_at','>',$today->format('Y-m-d')); } if ($request->input('carrier_id')){ $waybills=$waybills->where('carrier_id','=',$request->input('carrier_id')); } if ($request->input('owner_id')){ $waybills=$waybills->where('owner_id','=',$request->input('owner_id')); } if ($request->input('wms_bill_number')){ $waybills=$waybills->where('wms_bill_number','like','$'.$request->input('wms_bill_number').'%')->where('created_at','>',$today->format('Y-m-d')); } if ($request->input('created_at_start')){ $waybills=$waybills->where('created_at','>',$request->input('created_at_start')); } if ($request->input('created_at_end')){ $waybills=$waybills->where('created_at','<',$request->input('created_at_end')); } $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50); if (!$waybills&&$request->input('waybill_number')){ $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) { return $query->with('user'); }])->orderBy('id','DESC')->where('type','专线')->where('waybill_number',$request->input('waybill_number')) ->paginate($request->input('paginate')?$request->input('paginate'):50); } $carries = Carrier::get(); $owners = Owner::get(); return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'']); } else { $waybills = Waybill::with(['owner', 'waybillAuditLogs' => function ($query) { return $query->with('user'); }])->paginate(50); $carries = Carrier::get(); $owners = Owner::get(); return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'']); } } public function indexZF(Request $request){ if(!Gate::allows('运输管理-查询')){ return redirect(url('/')); } $data=$request->input(); if ($data != null ) { $today=Carbon::now()->subDays(15); $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) { return $query->with('user'); }])->orderBy('id','DESC')->where('type','直发车'); if ($request->input('waybill_number')){ $waybills =$waybills->where('waybill_number','like','%'.$request->input('waybill_number').'%')->where('created_at','>',$today->format('Y-m-d')); } if ($request->input('carrier_bill')){ $waybills=$waybills->where('carrier_bill','like','%'.$request->input('carrier_bill').'%')->where('created_at','>',$today->format('Y-m-d')); } if ($request->input('carrier_id')){ $waybills=$waybills->where('carrier_id','=',$request->input('carrier_id')); } if ($request->input('owner_id')){ $waybills=$waybills->where('owner_id','=',$request->input('owner_id')); } if ($request->input('wms_bill_number')){ $waybills=$waybills->where('wms_bill_number','like','$'.$request->input('wms_bill_number').'%')->where('created_at','>',$today->format('Y-m-d')); } if ($request->input('created_at_start')){ $waybills=$waybills->where('created_at','>',$request->input('created_at_start')); } if ($request->input('created_at_end')){ $waybills=$waybills->where('created_at','<',$request->input('created_at_end')); } $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50); if (!$waybills&&$request->input('waybill_number')){ $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) { return $query->with('user'); }])->orderBy('id','DESC')->where('type','专线')->where('waybill_number',$request->input('waybill_number')) ->paginate($request->input('paginate')?$request->input('paginate'):50); } $carries = Carrier::get(); $owners = Owner::get(); return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZF']); } else { $waybills = Waybill::with(['owner', 'waybillAuditLogs' => function ($query) { return $query->with('user'); }])->where('type','直发车')->paginate(50); $carries = Carrier::get(); $owners = Owner::get(); return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZF']); } } public function indexZX(Request $request){ if(!Gate::allows('运输管理-查询')){ return redirect(url('/')); } $data=$request->input(); if ($data != null ) { $today=Carbon::now()->subDays(15); $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) { return $query->with('user'); }])->orderBy('id','DESC')->where('type','专线'); if ($request->input('waybill_number')){ $waybills =$waybills->where('waybill_number','like','%'.$request->input('waybill_number').'%')->where('created_at','>',$today->format('Y-m-d')); } if ($request->input('carrier_bill')){ $waybills=$waybills->where('carrier_bill','like','%'.$request->input('carrier_bill').'%')->where('created_at','>',$today->format('Y-m-d')); } if ($request->input('carrier_id')){ $waybills=$waybills->where('carrier_id','=',$request->input('carrier_id')); } if ($request->input('owner_id')){ $waybills=$waybills->where('owner_id','=',$request->input('owner_id')); } if ($request->input('wms_bill_number')){ $waybills=$waybills->where('wms_bill_number','like','$'.$request->input('wms_bill_number').'%')->where('created_at','>',$today->format('Y-m-d')); } if ($request->input('created_at_start')){ $waybills=$waybills->where('created_at','>',$request->input('created_at_start')); } if ($request->input('created_at_end')){ $waybills=$waybills->where('created_at','<',$request->input('created_at_end')); } $waybills=$waybills->paginate($request->input('paginate')?$request->input('paginate'):50); if (!$waybills&&$request->input('waybill_number')){ $waybills=Waybill::with(['owner', 'waybillAuditLogs' => function ($query) { return $query->with('user'); }])->orderBy('id','DESC')->where('type','专线')->where('waybill_number',$request->input('waybill_number')) ->paginate($request->input('paginate')?$request->input('paginate'):50); } $carries = Carrier::get(); $owners = Owner::get(); return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZX']); } else { $waybills = Waybill::with(['owner', 'waybillAuditLogs' => function ($query) { return $query->with('user'); }])->where('type','专线')->paginate(50); $carries = Carrier::get(); $owners = Owner::get(); return view('waybill.index', ['waybills' => $waybills, 'carriers' => $carries, 'owners' => $owners,'filterData'=>$data,'uriType'=>'ZX']); } } public function create() { if(!Gate::allows('运输管理-录入')){ return redirect(url('/')); } $owners=Owner::get(); return view('waybill.create',['owners'=>$owners]); } public function createZF() { if(!Gate::allows('运输管理-录入')){ return redirect(url('/')); } $owners=Owner::get(); return view('waybill.create',['owners'=>$owners,'type'=>'直发车']); } public function createZX() { if(!Gate::allows('运输管理-录入')){ return redirect(url('/')); } $owners=Owner::get(); return view('waybill.create',['owners'=>$owners,'type'=>'专线']); } public function store(Request $request) { if(!Gate::allows('运输管理-录入')){ return redirect(url('/')); } $this->validatorWaybill($request)->validate(); $data=$request->input(); $waybill=new Waybill([ 'type'=>$data['type'], 'state'=>'未审核', 'waybill_number'=>Uuid::uuid1(), 'owner_id'=>$data['owner_id'], 'wms_bill_number'=>$data['wms_bill_number'], 'origination'=>$data['origination'], 'destination'=>$data['destination'], 'recipient'=>$data['recipient'], 'recipient_mobile'=>$data['recipient_mobile'], 'charge'=>$data['charge'], 'collect_fee'=>isset($data['collect_fee'])?$data['collect_fee']:0, 'ordering_remark'=>$data['ordering_remark'] ]); $waybill->save(); $number_id=$waybill->id; if ($data['type']=='直发车'){ $waybill_number='BSZF'.date ("ymd").str_pad($number_id>99999?$number_id%99999:$number_id,4,"0",STR_PAD_LEFT); $waybill->waybill_number=$waybill_number; $waybill->update(); }else{ $waybill_number='BSZX'.date ("ymd").str_pad($number_id>99999?$number_id%99999:$number_id,4,"0",STR_PAD_LEFT); $waybill->waybill_number=$waybill_number; $waybill->update(); } $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']); return redirect('waybill')->with('successTip','新运单“'.$waybill_number.'”录入成功'); } public function edit($id) { if(!Gate::allows('运输管理-编辑')){ return redirect(url('/')); } $waybill=Waybill::find($id); $carriers=Carrier::get(); $cities=City::get(); $units=Unit::get(); $carTypes=CarType::get(); return view('waybill/edit',['waybill'=>$waybill,'carriers'=>$carriers,'cities'=>$cities,'units'=>$units,'carTypes'=>$carTypes]); } public function update(Request $request, $id) { if(!Gate::allows('运输管理-调度')){ return redirect(url('/')); } $this->validatorWaybillDispatch($request)->validate(); $data=$request->input(); $waybill=Waybill::find($id); $waybill->fill($data); if ($waybill->save()){ if ($waybill->type=="直发车"){ $total_receivable=($waybill->charge); $total_expense=($waybill->fee)+($waybill->other_fee)-($waybill->collect_fee); }else if ($waybill->type=="专线"){ $waybillPriceModel_id=$request->input('waybillPriceModel'); if ($waybillPriceModel_id){ $carrier_weight=$request->input('carrier_weight'); $waybillPriceModel=WaybillPriceModel::find($waybillPriceModel_id); $carrier=Carrier::find($waybill->carrier_id); if ($carrier_weight<$waybillPriceModel->initial_weight){ $fee=(($waybillPriceModel->unit_price)*($waybillPriceModel->initial_weight))+$carrier->delivery_fee; }else{ $fee=(($waybillPriceModel->unit_price)*$carrier_weight)+$carrier->delivery_fee; } $waybill->fee=$fee; $waybill->waybill_price_model_id=$waybillPriceModel_id; } $waybill->save(); $total_receivable=($waybill->charge); $total_expense=($waybill->pick_up_fee)+($waybill->other_fee)+($waybill->fee); } $waybillPayoff=WaybillPayoff::where('waybill_id','=',$id)->first(); if ($waybillPayoff){ $waybillPayoff->waybill_id=$id; $waybillPayoff->total_expense=$total_expense; $waybillPayoff->total_receivable=$total_receivable; $waybillPayoff->gross_margin=$total_receivable-$total_expense; $waybillPayoff->gross_profit_rate=(($total_receivable-$total_expense)/$total_receivable); $waybillPayoff->save(); }else{ WaybillPayoff::create([ 'waybill_id'=>$id, 'total_expense'=>$total_expense, 'total_receivable'=>$total_receivable, 'gross_margin'=>$total_receivable-$total_expense, 'gross_profit_rate'=>(($total_receivable-$total_expense)/$total_receivable), ]); }; $this->log(__METHOD__,__FUNCTION__,json_encode($request->toArray()),Auth::user()['id']); return redirect('waybill')->with('successTip','运单“'.$waybill->waybill_number.'”调度成功'); } } public function isWaybillPriceModel(Request $request){ $carrier_id=$request->input('carrier_id'); $destination_city_id=$request->input('destination_city_id'); $carrier_weight=$request->input('carrier_weight'); $carrier_weight_unit_id=$request->input('carrier_weight_unit_id'); if(!$carrier_id)return['success'=>false]; if(!$destination_city_id)return['success'=>false]; if(!$carrier_weight)return['success'=>false]; if(!$carrier_weight_unit_id)return['success'=>false]; $waybillPriceModel=WaybillPriceModel::where('carrier_id',$carrier_id)->where('city_id',$destination_city_id) ->where('range_min','<',$carrier_weight)->where('range_max','>=',$carrier_weight) ->where('unit_id',$carrier_weight_unit_id)->first(); if($waybillPriceModel)return['success'=>$waybillPriceModel->id]; $waybillPriceModelRange=WaybillPriceModel::whereRaw('carrier_id = ? and city_id = ? and unit_id = ? and range_max is null',[$carrier_id,$destination_city_id,$carrier_weight_unit_id])->first(); if ($waybillPriceModelRange){ return ['success'=>$waybillPriceModelRange->id];} $city=City::where('id',$destination_city_id)->select('province_id')->first(); $waybillPriceModelProvince=WaybillPriceModel::whereRaw('carrier_id = ? and province_id = ? and unit_id = ? and range_max >= ? and range_min < ? and city_id is null', [$carrier_id,$city->province_id,$carrier_weight_unit_id,$carrier_weight,$carrier_weight])->first(); if ($waybillPriceModelProvince){return ['success'=>$waybillPriceModelProvince->id];} $waybillPriceModelProvinceRange=WaybillPriceModel::whereRaw('carrier_id = ? and province_id = ? and unit_id = ? and range_max is null and city_id is null', [$carrier_id,$city->province_id,$carrier_weight_unit_id])->first(); if ($waybillPriceModelProvinceRange){return ['success'=>$waybillPriceModelProvinceRange->id];}else{ return ['success'=>false]; } } public function waybillUpdate(Request $request, $id){ if(!Gate::allows('运输管理-编辑')){ return redirect(url('/')); } $this->validatorWaybill($request)->validate(); $data=$request->input(); $waybill=Waybill::find($id); $waybill->fill($data); if ($waybill->save()){ $this->log(__METHOD__,__FUNCTION__,json_encode($waybill),Auth::user()['id']); return redirect('waybill')->with('successTip','运单“'.$waybill->waybill_number.'”修改成功'); } } public function waybillAudit(Request $request){ if(!Gate::allows('运输管理-运单审核')){ return redirect(url('/')); } $id=$request->input('id'); $waybill=Waybill::find($id); $isAudit=WaybillAuditLog::whereRaw('waybill_id = ? and audit_stage = ?',[$id,"运单阶段"])->first(); if (empty($isAudit)){ $waybillAuditLog=new WaybillAuditLog([ 'waybill_id'=>$id, 'audit_stage'=>'运单阶段', 'user_id'=>Auth::id(), ]); $waybillAuditLog->save(); $waybillAuditLog['user']=Auth::user(); $waybill->state='已审核'; $result=$waybill->save(); $this->log(__METHOD__,__FUNCTION__,json_encode($waybill),Auth::user()['id']); return ['success'=>$result,'state'=>$waybill->state,'waybillAuditLog'=>$waybillAuditLog]; } return ['exception'=>'请勿重复审核!']; } public function waybillEdit($id){ if(!Gate::allows('运输管理-编辑')){ return redirect(url('/')); } $waybill=Waybill::find($id); $owners=Owner::get(); return view('waybill.waybillEdit',['waybill'=>$waybill,'owners'=>$owners]); } public function waybillRetreatAudit(Request $request){ if(!Gate::allows('运输管理-调度')){ return redirect(url('/')); } $id=$request->input('id'); $waybill=Waybill::find($id); WaybillAuditLog::whereRaw('waybill_id = ? and audit_stage = ?',[$id,"运单阶段"])->delete(); $waybill->state='待重审'; $result=$waybill->save(); $this->log(__METHOD__,__FUNCTION__,json_encode($waybill),Auth::user()['id']); return ['success'=>$result,'state'=>$waybill->state]; } public function waybillEndAudit(Request $request){ if(!Gate::allows('运输管理-调度审核')){ return redirect(url('/')); } $id=$request->input('id'); $waybill=Waybill::find($id); $isAudit=WaybillAuditLog::whereRaw('waybill_id = ? and audit_stage = ?',[$id,"调度阶段"])->first(); if (empty($isAudit)){ $waybillAuditLog=new WaybillAuditLog([ 'waybill_id'=>$id, 'audit_stage'=>'调度阶段', 'user_id'=>Auth::id(), ]); $waybillAuditLog->save(); $waybillAuditLog['user']=Auth::user(); if ($waybill->waybill_price_model_id||$waybill->type=='直发车'){ $waybill->state='完结'; $result=$waybill->save(); $waybillPayoff=WaybillPayoff::where('waybill_id','=',$id)->first(); $waybillPayoff->load(["waybill"]); $waybillPayoff->waybill->load(["owner","carrier","origination_city","destination_city","warehouse_weight_unit","carrier_weight_unit","carType","waybillAuditLogs"]); $waybillPayoff->waybill->waybillAuditLogs->load(["user"]); $waybillPayoffJson=json_encode($waybillPayoff,JSON_UNESCAPED_UNICODE); WaybillFinancialSnapshot::create([ 'waybill_id'=>$id, 'json_content'=>$waybillPayoffJson, ]); }else{ $waybill->state='未定义计费模型'; $result=$waybill->save(); $waybillPayoff=WaybillPayoff::where('waybill_id','=',$id)->first(); $waybillPayoff->load(["waybill"]); $waybillPayoff->waybill->load(["owner","carrier","origination_city","destination_city","warehouse_weight_unit","carrier_weight_unit","carType","waybillAuditLogs"]); $waybillPayoff->waybill->waybillAuditLogs->load(["user"]); $waybillPayoffJson=json_encode($waybillPayoff,JSON_UNESCAPED_UNICODE); WaybillFinancialExcepted::create([ 'waybill_id'=>$id, 'json_content'=>$waybillPayoffJson, ]); } $this->log(__METHOD__,__FUNCTION__,$waybillPayoffJson,Auth::user()['id']); return ['success'=>$result,'state'=>$waybill->state,'waybillAuditLog'=>$waybillAuditLog]; } return ['exception'=>'请勿重复审核!']; } public function waybillExport($id){ $id = explode( ',',$id); $row=[[ 'type'=>'运单类型', 'waybill_number'=>'运单号', 'owner'=>'货主', 'wms_bill_number'=>'WMS单号', 'origination'=>'始发地', 'destination'=>'目的地', 'recipient'=>'收件人', 'recipient_mobile'=>'收件人电话', 'charge'=>'收费(元)', 'ordering_remark'=>'下单备注', 'carrier'=>'承运商', 'carrier_bill'=>'承运商单号', 'origination_city'=>'始发市', 'destination_city'=>'目的市', 'warehouse_weight'=>'仓库计重(抛)', 'warehouse_weight_unit'=>'仓库计重单位 ', 'carrier_weight'=>'承运商计重(抛)', 'carrier_weight_unit'=>'承运商计重单位', 'carType'=>'车型', 'car_owner_info'=>'车辆信息', 'fee'=>'运费(元)', 'pick_up_fee'=>'提货费(元)', 'other_fee'=>'其他费用(元)', 'collect_fee'=>'到付金额(元)', 'dispatch_remark'=>'调度备注', 'waybillAuditor'=>'运单审核人', 'dispatchAuditor'=>'调度审核人', 'created_at'=>'创建时间' ]]; $feeVisible=true; if(!Gate::allows('运输管理-可见费用项')){ $feeVisible=false; unset($row[0]['fee'],$row[0]['pick_up_fee'],$row[0]['other_fee'],$row[0]['collect_fee']); } $list=[]; for ($i=0; $i function ($query) { return $query->with('user'); }])->find($id[$i]); foreach ($waybill->waybillAuditLogs as $waybillAuditLog){ if ($waybillAuditLog->audit_stage=="运单阶段"){ $waybillAuditor=$waybillAuditLog->user->name; }else{ $waybillAuditor=''; } if ($waybillAuditLog->audit_stage=="调度阶段"){ $dispatchAuditor=$waybillAuditLog->user->name; }else{ $dispatchAuditor=''; } }; $w=[ 'type'=>isset($waybill->type)?$waybill->type:'', 'waybill_number'=>isset($waybill->waybill_number)?$waybill->waybill_number:'', 'owner'=>isset($waybill->owner->name)?$waybill->owner->name:'', 'wms_bill_number'=>isset($waybill->wms_bill_number)?$waybill->wms_bill_number:'', 'origination'=>isset($waybill->origination)?$waybill->origination:'', 'destination'=>isset($waybill->destination)?$waybill->destination:'', 'recipient'=>isset($waybill->recipient)?$waybill->recipient:'', 'recipient_mobile'=>isset($waybill->recipient_mobile)?$waybill->recipient_mobile:'', 'charge'=>isset($waybill->charge)?$waybill->charge:'', 'ordering_remark'=>isset($waybill->ordering_remark)?$waybill->ordering_remark:'', 'carrier'=>isset($waybill->carrier_name)?$waybill->carrier_name:'', 'carrier_bill'=>isset($waybill->carrier_bill)?$waybill->carrier_bill:'', 'origination_city'=>isset($waybill->origination_city_name)?$waybill->origination_city_name:'', 'destination_city'=>isset($waybill->destination_city_name)?$waybill->destination_city_name:'', 'warehouse_weight'=>isset($waybill->warehouse_weight)?$waybill->warehouse_weight:'', 'warehouse_weight_unit'=>isset($waybill->warehouse_weight_unit_name)?$waybill->warehouse_weight_unit_name:'', 'carrier_weight'=>isset($waybill->carrier_weight)?$waybill->carrier_weight:'', 'carrier_weight_unit'=>isset($waybill->carrier_weight_unit_name)?$waybill->carrier_weight_unit_name:'', 'carType'=>isset($waybill->carType->name)?$waybill->carType->name.($waybill->carType->length.'米'):'', 'car_owner_info'=>isset($waybill->car_owner_info)?$waybill->car_owner_info:'', 'fee'=>isset($waybill->fee)?$waybill->fee:'', 'pick_up_fee'=>isset($waybill->pick_up_fee)?$waybill->pick_up_fee:'', 'other_fee'=>isset($waybill->other_fee)?$waybill->other_fee:'', 'collect_fee'=>isset($waybill->collect_fee)?$waybill->collect_fee:'', 'dispatch_remark'=>isset($waybill->dispatch_remark)?$waybill->dispatch_remark:'', 'waybillAuditor'=>isset($waybillAuditor)?$waybillAuditor:'', 'dispatchAuditor'=>isset($dispatchAuditor)?$dispatchAuditor:'', 'created_at'=>isset($waybill->created_at)?$waybill->created_at:'' ]; if(!$feeVisible){ unset($w['fee'],$w['pick_up_fee'],$w['other_fee'],$w['collect_fee']); } $list[$i]=$w; } $this->log(__METHOD__,__FUNCTION__,json_encode($waybill),Auth::user()['id']); return Excel::download(new WaybillExport($row,$list), date('Y:m:d ') . '运单列表.xls'); } protected function validatorWaybill(Request $request){ $validator=Validator::make($request->input(),[ 'owner_id'=>'required', 'wms_bill_number'=>'nullable|alpha_num|max:50|unique:waybills,wms_bill_number', 'origination'=>'required|max:255', 'destination'=>'required|max:255', 'recipient'=>'required|max:50', 'recipient_mobile'=>['required','regex:/^([\d]{6,11})|(1[3|4|5|7|8][0-9]\d{4,8})$/'], 'charge'=>'nullable|numeric|max:999999', 'collect_fee'=>'nullable|min:0|numeric', ],[ 'required'=>':attribute 为必填项', 'alpha_num'=>':attribute 应为字母或数字', 'max'=>':attribute 超过最大位数', 'regex'=>':attribute 输入有误', 'integer'=>':attribute 应为整数', 'min'=>':attribute 不得为负', 'numeric'=>':attribute 应为数字', 'unique'=>':attribute 已存在', ],[ 'owner_id'=>'货主', 'wms_bill_number'=>'WMS单号', 'origination'=>'始发地', 'destination'=>'目的地', 'recipient'=>'收件人', 'recipient_mobile'=>'收件人电话', 'charge'=>'收费', 'collect_fee'=>'到付金额', ]); return $validator; } protected function validatorWaybillDispatch(Request $request){ if ($request->input('type')=='直发车'){ $validator=Validator::make($request->input(),[ 'carrier_bill'=>'required|alpha_num|max:50|unique:waybills,carrier_bill', 'fee'=>'required|min:0|numeric', 'other_fee'=>'nullable|min:0|numeric', ],[ 'required'=>':attribute 为必填项', 'alpha_num'=>':attribute 应为字母或数字', 'max'=>':attribute 字符过多', 'min'=>':attribute 不得为负', 'numeric'=>':attribute 应为数字', 'unique'=>':attribute 已存在', ],[ 'carrier_bill'=>'承运商单号', 'fee'=>'运费', 'other_fee'=>'其他费用', ]); return $validator; }else if ($request->input('type')=='专线'){ $validator=Validator::make($request->input(),[ 'carrier_bill'=>'required|alpha_num|max:50|unique:waybills,carrier_bill', 'warehouse_weight'=>'required|min:0|numeric', 'carrier_weight'=>'required|min:0|numeric', 'pick_up_fee'=>'required|min:0|numeric', 'other_fee'=>'nullable|min:0|numeric', 'carrier_id'=>'required|integer', 'destination_city_id'=>'required|integer', 'carrier_weight_unit_id'=>'required|integer', ],[ 'required'=>':attribute 为必填项', 'alpha_num'=>':attribute 应为字母或数字', 'max'=>':attribute 字符过多', 'min'=>':attribute 不得为负', 'numeric'=>':attribute 应为数字', 'unique'=>':attribute 已存在', ],[ 'carrier_bill'=>'承运商单号', 'warehouse_weight'=>'仓库计重(抛)', 'carrier_weight'=>'承运商计重(抛)', 'pick_up_fee'=>'提货费', 'other_fee'=>'其他费用', 'carrier_id'=>'承运商', 'destination_city_id'=>'目的市', 'carrier_weight_unit_id'=>'承运商计重单位', ]); return $validator; }else{ return false; } } }