| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace App\Services;
- use App\Services\common\QueryService;
- use App\Waybill;
- use Illuminate\Http\Request;
- Class WaybillService
- {
- private function conditionQuery(Request $request){
- $waybills = Waybill::with(['owner','wmsCommodities','waybillAuditLogs' => function ($query) {
- return $query->with('user');
- }])->selectRaw('waybills.* ,waybill_on_tops.id top_id ,waybill_on_tops.remark,waybill_on_tops.updated_at top_update')
- ->leftJoin('waybill_on_tops','waybill_on_tops.waybill_id','=','waybills.id')
- ->whereNull('waybill_on_tops.deleted_at')
- ->orderBy('waybill_on_tops.updated_at','desc')
- ->orderBy('waybills.id','desc');
- $columnQueryRules=[
- 'waybill_number' => ['timeLimit' => 15],
- 'carrier_bill' => ['timeLimit' => 15],
- 'owner_id' => ['multi' => ','],
- 'wms_bill_number' => ['timeLimit' => 15],
- 'origination' => ['timeLimit' => 15],
- 'destination' => ['timeLimit' => 15],
- 'created_at_start' => ['alias' => 'created_at' , 'startDate' => ' 00:00:00'],
- 'created_at_end' => ['alias' => 'created_at' , 'endDate' => ' 23:59:59'],
- 'uriType' => ['alias' => 'type']
- ];
- $waybills = app(QueryService::class)->query($request,$waybills,$columnQueryRules,"waybills");
- return $waybills;
- }
- public function paginate(Request $request){
- $waybills = $this->conditionQuery($request);
- return $waybills->paginate($request->paginate ?? 50);
- }
- public function get(Request $request){
- $waybills = $this->conditionQuery($request);
- return $waybills->get();
- }
- public function some(Request $request){
- return $waybills = Waybill::with(['owner'])->selectRaw('waybills.* ,waybill_on_tops.id top_id ,waybill_on_tops.remark,waybill_on_tops.updated_at top_update')
- ->leftJoin('waybill_on_tops','waybill_on_tops.waybill_id','=','waybills.id')
- ->whereNull('waybill_on_tops.deleted_at')
- ->orderBy('waybill_on_tops.updated_at','desc')
- ->orderBy('waybills.id','desc')
- ->whereIn('id',explode(',',$request->data))
- ->get();
- }
- }
|