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

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