123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <?php
-
- namespace App\Http\Controllers;
-
- use App\Model\Company;
- use App\Model\DealerClaim;
- use App\Model\Docket;
- use App\Model\Form;
- use App\Model\FormStatus;
- use App\Model\PackageDetail;
- use App\Model\Product;
- use App\Model\StaffDetail;
- use App\Model\Subscriber;
- use App\Model\WorkOrder;
- use App\Staff;
- use Carbon\Carbon;
- use Illuminate\Foundation\Bus\DispatchesJobs;
- use Illuminate\Routing\Controller as BaseController;
- use Illuminate\Foundation\Validation\ValidatesRequests;
- use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
- use Illuminate\Http\Request;
- use Mockery\Matcher\Subset;
-
- class Controller extends BaseController
- {
- use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
-
- public function updateAddress()
- {
- $subscribers = Subscriber::all();
-
- foreach ($subscribers as $key => $a) {
- if ($a->unit_no != '' || $a->unit_no != null) {
- $a->unit_no = strtoupper($a->unit_no);
- }
- if ($a->building_name != '' || $a->building_name != null) {
- $a->building_name = strtoupper($a->building_name);
- }
- if ($a->street != '' || $a->street != null) {
- $a->street = strtoupper($a->street);
- }
- if ($a->city != '' || $a->city != null) {
- $a->city = strtoupper($a->city);
- }
- if ($a->state != '' || $a->state != null) {
- $a->state = strtoupper($a->state);
- }
- $a->save();
- }
-
- return "Done standardize city in DB";
- }
-
- public function standardizeAddress()
- {
- $response = json_decode(file_get_contents(public_path() . '/test.json'));
-
- if ($response->success == true) {
-
- foreach ($response->data as $key => $r) {
- $subscriber = Subscriber::where('subscriber_id', $r->subscriber_id)->first();
-
- if (!empty($subscriber)) {
- $subscriber->city = $r->city;
- $subscriber->state = $r->state;
- $subscriber->save();
- }
- }
-
- return count($response);
- }
- }
-
- public function updatePromoPrice()
- {
- $product = Product::where('formT', 'R')->where('speed', '50')->first();
- $product->promotion_price = "69";
- $product->save();
-
- $product1 = Product::where('formT', 'R')->where('speed', '100')->first();
- $product1->promotion_price = "89";
- $product1->save();
-
- $product2 = Product::where('formT', 'R')->where('speed', '500')->first();
- $product2->promotion_price = "129";
- $product2->save();
-
- $product3 = Product::where('formT', 'B')->where('speed', '50')->first();
- $product3->promotion_price = "89";
- $product3->save();
-
- $product4 = Product::where('formT', 'B')->where('speed', '100')->first();
- $product4->promotion_price = "119";
- $product4->save();
-
- $product5 = Product::where('formT', 'B')->where('speed', '300')->first();
- $product5->promotion_price = "179";
- $product5->save();
-
- $product6 = Product::where('formT', 'B')->where('speed', '500')->first();
- $product6->promotion_price = "249";
- $product6->save();
-
- return 'promo price update';
- }
-
- public function resetDocket(Request $request)
- {
- $docket = Docket::where('docket_id', $request->docket_id)->first();
-
- $work_order = WorkOrder::where('wo', $docket->work_order_id)->first();
- $work_order->docket_id = "";
- $work_order->status = "Pending Installer";
- $work_order->save();
-
- $claim = DealerClaim::where('docket', $request->docket_id)->first();
- if (!empty($claim)) {
- $claim->forceDelete();
- }
-
- $docket->forceDelete();
- }
-
- public function createNewCredential(Request $request)
- {
- $staffD = new StaffDetail;
- $staffD->name = 'Uhanis';
- $staffD->ic = '-';
- $staffD->email = 'uhanis@gmail.com';
- $staffD->phone = '-';
- $staffD->company_id = '5b0e0375ee0dc2b6a20694b9';
- $staffD->color = '';
- $staffD->position = 'Marketing';
- $staffD->password = 'b3NsNHdxTndsUFBzNlhsMi9xVWxMUT09';
- $staffD->user_pic = 'assets/avatar/user.png';
-
- // Save Login Staff
- $loginD = new Staff;
- $loginD->email = 'uhanis@gmail.com';
- $loginD->password = 'b3NsNHdxTndsUFBzNlhsMi9xVWxMUT09';
- $loginD->roles_access = 'Marketing';
- $loginD->company_id = '5b0e0375ee0dc2b6a20694b9';
- $loginD->last_login_at = '';
- $loginD->last_login_ip = '';
- $loginD->created_at = Carbon::createFromDate(2020, 1)->toDateTimeString();
-
- $company = Company::where('_id','5b0e0375ee0dc2b6a20694b9')->first();
- $company->staff()->save($loginD);
- $loginD->staffdetail()->save($staffD);
- }
-
- public function getDatabase(Request $request)
- {
- $staff = Staff::with('staffdetail')->where('email', 'dealer@test.my')->first();
- $company = Company::where('name', 'TNBX Sdn Bhd')->first();
- $staff->company_id = $company->_id;
- $staff->save();
- $staffD = StaffDetail::where('_id',$staff->_id)->first();
- $staffD->company_id = $company->_id;
- $staffD->save();
-
- return $company . $staff . $staffD;
- }
-
- public function adjustInstaller(Request $request){
- $wo = WorkOrder::where('installer_id', $request->id)->where('status', 'like', '%Pending%')->get();
- foreach ($wo as $w) {
- $w->status = "Pending Contractor";
- $w->installer_id = "";
- $w->save();
- }
- }
- }
|