您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Controller.php 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Model\Company;
  4. use App\Model\DealerClaim;
  5. use App\Model\Docket;
  6. use App\Model\Form;
  7. use App\Model\FormStatus;
  8. use App\Model\PackageDetail;
  9. use App\Model\Product;
  10. use App\Model\StaffDetail;
  11. use App\Model\Subscriber;
  12. use App\Model\WorkOrder;
  13. use App\Staff;
  14. use Carbon\Carbon;
  15. use Illuminate\Foundation\Bus\DispatchesJobs;
  16. use Illuminate\Routing\Controller as BaseController;
  17. use Illuminate\Foundation\Validation\ValidatesRequests;
  18. use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
  19. use Illuminate\Http\Request;
  20. use Mockery\Matcher\Subset;
  21. class Controller extends BaseController
  22. {
  23. use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
  24. public function updateAddress()
  25. {
  26. $subscribers = Subscriber::all();
  27. foreach ($subscribers as $key => $a) {
  28. if ($a->unit_no != '' || $a->unit_no != null) {
  29. $a->unit_no = strtoupper($a->unit_no);
  30. }
  31. if ($a->building_name != '' || $a->building_name != null) {
  32. $a->building_name = strtoupper($a->building_name);
  33. }
  34. if ($a->street != '' || $a->street != null) {
  35. $a->street = strtoupper($a->street);
  36. }
  37. if ($a->city != '' || $a->city != null) {
  38. $a->city = strtoupper($a->city);
  39. }
  40. if ($a->state != '' || $a->state != null) {
  41. $a->state = strtoupper($a->state);
  42. }
  43. $a->save();
  44. }
  45. return "Done standardize city in DB";
  46. }
  47. public function standardizeAddress()
  48. {
  49. $response = json_decode(file_get_contents(public_path() . '/test.json'));
  50. if ($response->success == true) {
  51. foreach ($response->data as $key => $r) {
  52. $subscriber = Subscriber::where('subscriber_id', $r->subscriber_id)->first();
  53. if (!empty($subscriber)) {
  54. $subscriber->city = $r->city;
  55. $subscriber->state = $r->state;
  56. $subscriber->save();
  57. }
  58. }
  59. return count($response);
  60. }
  61. }
  62. public function updatePromoPrice()
  63. {
  64. $product = Product::where('formT', 'R')->where('speed', '50')->first();
  65. $product->promotion_price = "69";
  66. $product->save();
  67. $product1 = Product::where('formT', 'R')->where('speed', '100')->first();
  68. $product1->promotion_price = "89";
  69. $product1->save();
  70. $product2 = Product::where('formT', 'R')->where('speed', '500')->first();
  71. $product2->promotion_price = "129";
  72. $product2->save();
  73. $product3 = Product::where('formT', 'B')->where('speed', '50')->first();
  74. $product3->promotion_price = "89";
  75. $product3->save();
  76. $product4 = Product::where('formT', 'B')->where('speed', '100')->first();
  77. $product4->promotion_price = "119";
  78. $product4->save();
  79. $product5 = Product::where('formT', 'B')->where('speed', '300')->first();
  80. $product5->promotion_price = "179";
  81. $product5->save();
  82. $product6 = Product::where('formT', 'B')->where('speed', '500')->first();
  83. $product6->promotion_price = "249";
  84. $product6->save();
  85. return 'promo price update';
  86. }
  87. public function resetDocket(Request $request)
  88. {
  89. $docket = Docket::where('docket_id', $request->docket_id)->first();
  90. $work_order = WorkOrder::where('wo', $docket->work_order_id)->first();
  91. $work_order->docket_id = "";
  92. $work_order->status = "Pending Installer";
  93. $work_order->save();
  94. $claim = DealerClaim::where('docket', $request->docket_id)->first();
  95. if (!empty($claim)) {
  96. $claim->forceDelete();
  97. }
  98. $docket->forceDelete();
  99. }
  100. public function createNewCredential(Request $request)
  101. {
  102. $staffD = new StaffDetail;
  103. $staffD->name = 'Uhanis';
  104. $staffD->ic = '-';
  105. $staffD->email = 'uhanis@gmail.com';
  106. $staffD->phone = '-';
  107. $staffD->company_id = '5b0e0375ee0dc2b6a20694b9';
  108. $staffD->color = '';
  109. $staffD->position = 'Marketing';
  110. $staffD->password = 'b3NsNHdxTndsUFBzNlhsMi9xVWxMUT09';
  111. $staffD->user_pic = 'assets/avatar/user.png';
  112. // Save Login Staff
  113. $loginD = new Staff;
  114. $loginD->email = 'uhanis@gmail.com';
  115. $loginD->password = 'b3NsNHdxTndsUFBzNlhsMi9xVWxMUT09';
  116. $loginD->roles_access = 'Marketing';
  117. $loginD->company_id = '5b0e0375ee0dc2b6a20694b9';
  118. $loginD->last_login_at = '';
  119. $loginD->last_login_ip = '';
  120. $loginD->created_at = Carbon::createFromDate(2020, 1)->toDateTimeString();
  121. $company = Company::where('_id','5b0e0375ee0dc2b6a20694b9')->first();
  122. $company->staff()->save($loginD);
  123. $loginD->staffdetail()->save($staffD);
  124. }
  125. public function getDatabase(Request $request)
  126. {
  127. $staff = Staff::with('staffdetail')->where('email', 'dealer@test.my')->first();
  128. $company = Company::where('name', 'TNBX Sdn Bhd')->first();
  129. $staff->company_id = $company->_id;
  130. $staff->save();
  131. $staffD = StaffDetail::where('_id',$staff->_id)->first();
  132. $staffD->company_id = $company->_id;
  133. $staffD->save();
  134. return $company . $staff . $staffD;
  135. }
  136. public function adjustInstaller(Request $request){
  137. $wo = WorkOrder::where('installer_id', $request->id)->where('status', 'like', '%Pending%')->get();
  138. foreach ($wo as $w) {
  139. $w->status = "Pending Contractor";
  140. $w->installer_id = "";
  141. $w->save();
  142. }
  143. }
  144. }