You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Controller.php 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Model\DealerClaim;
  4. use App\Model\Docket;
  5. use App\Model\Form;
  6. use App\Model\Product;
  7. use App\Model\StaffDetail;
  8. use App\Model\Subscriber;
  9. use App\Model\WorkOrder;
  10. use App\Staff;
  11. use Illuminate\Foundation\Bus\DispatchesJobs;
  12. use Illuminate\Routing\Controller as BaseController;
  13. use Illuminate\Foundation\Validation\ValidatesRequests;
  14. use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
  15. use Illuminate\Http\Request;
  16. class Controller extends BaseController
  17. {
  18. use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
  19. public function updateAddress()
  20. {
  21. $subscribers = Subscriber::all();
  22. foreach ($subscribers as $key => $a) {
  23. if($a->unit_no != '' || $a->unit_no != null){
  24. $a->unit_no = strtoupper($a->unit_no);
  25. }
  26. if ($a->building_name != '' || $a->building_name != null) {
  27. $a->building_name = strtoupper($a->building_name);
  28. }
  29. if ($a->street != '' || $a->street != null) {
  30. $a->street = strtoupper($a->street);
  31. }
  32. if ($a->city != ''|| $a->city != null) {
  33. $a->city = strtoupper($a->city);
  34. }
  35. if ($a->state != ''|| $a->state != null) {
  36. $a->state = strtoupper($a->state);
  37. }
  38. $a->save();
  39. }
  40. return "Done standardize city in DB";
  41. }
  42. public function taggingCategory()
  43. {
  44. $response = json_decode(file_get_contents(public_path() . '/test.json'));
  45. if ($response->success == true) {
  46. foreach ($response->data as $key => $r) {
  47. $work_order = WorkOrder::where('wo', $r->wo)->first();
  48. if (!empty($work_order)) {
  49. $form_submitted = Form::where('_id', $work_order->_id)->first();
  50. $form_submitted->customer_category = $r->category;
  51. $form_submitted->save();
  52. }
  53. }
  54. return 'data inserted ';
  55. }
  56. }
  57. public function updatePromoPrice()
  58. {
  59. $product = Product::where('formT', 'R')->where('speed', '50')->first();
  60. $product->promotion_price = "69";
  61. $product->save();
  62. $product1 = Product::where('formT','R')->where('speed','100')->first();
  63. $product1->promotion_price = "89";
  64. $product1->save();
  65. $product2 = Product::where('formT', 'R')->where('speed', '500')->first();
  66. $product2->promotion_price = "129";
  67. $product2->save();
  68. $product3 = Product::where('formT', 'B')->where('speed', '50')->first();
  69. $product3->promotion_price = "89";
  70. $product3->save();
  71. $product4 = Product::where('formT', 'B')->where('speed', '100')->first();
  72. $product4->promotion_price = "119";
  73. $product4->save();
  74. $product5 = Product::where('formT', 'B')->where('speed', '300')->first();
  75. $product5->promotion_price = "179";
  76. $product5->save();
  77. $product6 = Product::where('formT', 'B')->where('speed', '500')->first();
  78. $product6->promotion_price = "249";
  79. $product6->save();
  80. return 'promo price update';
  81. }
  82. public function deleteTodayClaim()
  83. {
  84. $claim = DealerClaim::where('activated_my', '12/2020')->orWhere('activated_my','11/2020')->get();
  85. foreach ($claim as $key => $c) {
  86. # code...
  87. $c->forceDelete();
  88. }
  89. return 'done delete';
  90. }
  91. public function resetDocket(Request $request)
  92. {
  93. $docket = Docket::where('docket_id',$request->docket_id)->first();
  94. $work_order = WorkOrder::where('wo',$docket->work_order_id)->first();
  95. $work_order->installer_id = "";
  96. $work_order->docket_id = "";
  97. $work_order->status = "Pending Contractor";
  98. $work_order->save();
  99. $claim = DealerClaim::where('docket',$request->docket_id)->first();
  100. if(!empty($claim)){
  101. $claim->forceDelete();
  102. }
  103. $docket->forceDelete();
  104. }
  105. public function tukarCompanyTest()
  106. {
  107. // $dealer = Staff::where('email', 'dealer@test.my')->first();
  108. // $dealer->company_id = "5c36baf2ded8f6068d769952";
  109. // $dealer->save();
  110. // $details = StaffDetail::where('_id',$dealer->_id)->first();
  111. // $details->company_id = "5c36baf2ded8f6068d769952";
  112. // $details->save();
  113. $dealer_claimAll = DealerClaim::where('dealer', '5c36baf2ded8f6068d769952')->orderBy('activated_dt', 'desc')->get();
  114. return $dealer_claimAll;
  115. }
  116. }