| namespace App\Http\Controllers; | namespace App\Http\Controllers; | ||||
| use App\Model\Coverage; | |||||
| use App\Model\Form; | |||||
| use App\Model\WorkOrder; | |||||
| use Illuminate\Foundation\Bus\DispatchesJobs; | use Illuminate\Foundation\Bus\DispatchesJobs; | ||||
| use Illuminate\Routing\Controller as BaseController; | use Illuminate\Routing\Controller as BaseController; | ||||
| use Illuminate\Foundation\Validation\ValidatesRequests; | use Illuminate\Foundation\Validation\ValidatesRequests; | ||||
| { | { | ||||
| use AuthorizesRequests, DispatchesJobs, ValidatesRequests; | use AuthorizesRequests, DispatchesJobs, ValidatesRequests; | ||||
| public function taggingCategory(){ | |||||
| public function taggingCategory() | |||||
| { | |||||
| $response = json_decode(file_get_contents(public_path() . '/test.json')); | $response = json_decode(file_get_contents(public_path() . '/test.json')); | ||||
| if ($response->success == true) { | if ($response->success == true) { | ||||
| foreach ($response->data as $key => $r) { | foreach ($response->data as $key => $r) { | ||||
| $coverage = Coverage::where(strtoupper('building_name'),strtoupper($r->building_name))->where(strtoupper('street'),strtoupper($r->street))->where('Type',$r->Type)->get(); | |||||
| if(count($coverage)==0){ | |||||
| $coveragedetails = [ | |||||
| 'Type' => $r->Type, | |||||
| 'building_name' => strtoupper($r->building_name), | |||||
| 'project_type' => $r->project_type, | |||||
| 'street' => strtoupper($r->street), | |||||
| 'city' => strtoupper($r->city), | |||||
| 'state' => strtoupper($r->state), | |||||
| 'postcode' => $r->postcode, | |||||
| 'installation_fee' => $r->installation_fee, | |||||
| 'status_building' => $r->status_building, | |||||
| 'jmb_email' => "", | |||||
| ]; | |||||
| $coverageUpdate = Coverage::create($coveragedetails); | |||||
| }else{ | |||||
| } | |||||
| $work_order = WorkOrder::where('wo', $r->wo)->first(); | |||||
| $form_submitted = Form::where('id', $work_order->_id)->first(); | |||||
| $form_submitted->customer_category = $r->category; | |||||
| $form_submitted->save(); | |||||
| } | } | ||||
| return 'data inserted ' ; | |||||
| return 'data inserted '; | |||||
| } | } | ||||
| } | } | ||||
| } | } |