WaybillFinancialExceptedController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\WaybillPriceModel;
  4. use App\Events\WaybillPriceModelEvent;
  5. use App\WaybillFinancialExcepted;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Support\Facades\Event;
  8. use Illuminate\Support\Facades\Gate;
  9. class WaybillFinancialExceptedController extends Controller
  10. {
  11. public function conditionQuery(Request $request,$waybillFinancialSnapshots){
  12. if ($request->input('created_at_start')){
  13. $created_at_start=$request->input('created_at_start')." 00:00:00";
  14. $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','>=',$created_at_start);
  15. }
  16. if ($request->input('created_at_end')){
  17. $created_at_end=$request->input('created_at_end')." 23:59:59";
  18. $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('created_at','<=',$created_at_end);
  19. }
  20. $waybillFinancialSnapshots=$waybillFinancialSnapshots->paginate(50);
  21. return $waybillFinancialSnapshots;
  22. }
  23. public function index(Request $request)
  24. {
  25. if(!Gate::allows('财务报表')){ return redirect(url('/')); }
  26. $waybillFinancialSnapshots=WaybillFinancialExcepted::query()->orderBy('id', 'DESC');
  27. $type='';
  28. if ($request->type=='ZF'){
  29. $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('json_content','like','%直发车%');
  30. $type='ZF';
  31. }
  32. if ($request->type=='ZX'){
  33. $waybillFinancialSnapshots=$waybillFinancialSnapshots->where('json_content','like','%专线%');
  34. $type='ZX';
  35. }
  36. $waybillFinancialSnapshots=$this->conditionQuery($request,$waybillFinancialSnapshots);
  37. return view('transport.waybill.waybillFinancialSnapshot.index',['waybillFinancialSnapshots'=>$waybillFinancialSnapshots,'filterData'=>$request->input(),'type'=>$type,'excepted'=>true]);
  38. }
  39. }