stdClass error

This commit is contained in:
2019-05-29 22:13:48 -05:00
parent ea1b802f77
commit acc7da2c07

View File

@@ -90,14 +90,14 @@ class ProcessStructureJob implements ShouldQueue
$structures = $this->GetListOfStructures(); $structures = $this->GetListOfStructures();
foreach($structures as $structure) { foreach($structures as $structure) {
$info = $this->GetStructureInfo($structure['structure_id']); $info = $this->GetStructureInfo($structure->structure_id);
$solarName = $this->GetSolarSystemName($info['solar_system_id']); $solarName = $this->GetSolarSystemName($info->solar_system_id);
//Record the structure information into the database //Record the structure information into the database
//Find if the structure exists //Find if the structure exists
$found = Structure::where(['structure_id' => $structure['structure_id']])->get(); $found = Structure::where(['structure_id' => $structure->structure_id])->get();
if($found) { if($found) {
$this->UpdateExistingStructure($structure, $info, $solarName); $this->UpdateExistingStructure($structure, $info, $solarName);
} else { } else {
@@ -110,25 +110,25 @@ class ProcessStructureJob implements ShouldQueue
//For each line see if it is part of the structure array, and attempt to modify each variable //For each line see if it is part of the structure array, and attempt to modify each variable
//This will be implemented in the near future. //This will be implemented in the near future.
if(isset($structures['services'])) { if(isset($structure->services)) {
foreach($structure['service'] as $service) { foreach($structure->service as $service) {
//Search for the service, and if found, update it, else add it. //Search for the service, and if found, update it, else add it.
$serviceFound = Service::where([ $serviceFound = Service::where([
'structure_id' => $structure['structure_id'], 'structure_id' => $structure->structure_id,
'name' => $service['name'], 'name' => $service->name,
])->get(); ])->get();
if($serviceFound) { if($serviceFound) {
Service::where([ Service::where([
'structure_id' => $structure['structure_id'], 'structure_id' => $structure->structure_id,
'name' => $service['name'], 'name' => $service->name,
])->update([ ])->update([
'state' => $service['state'], 'state' => $service->state,
]); ]);
} else { } else {
$newService = new Service; $newService = new Service;
$newService->structure_id = $structure['structure_id']; $newService->structure_id = $structure->structure_id;
$newService->name = $service['name']; $newService->name = $service->name;
$newService->state = $service['state']; $newService->state = $service->state;
} }
} }
@@ -137,52 +137,52 @@ class ProcessStructureJob implements ShouldQueue
private function StoreNewStructure($structure, $info, $solarName) { private function StoreNewStructure($structure, $info, $solarName) {
$structure = new Structure; $structure = new Structure;
$structure->structure_id = $structure['structure_id']; $structure->structure_id = $structure->structure_id;
$structure->structure_name = $info['name']; $structure->structure_name = $info->name;
$structure->corporation_id = $info['owner_id']; $structure->corporation_id = $info->owner_id;
$structure->solar_system_id = $info['solar_system_id']; $structure->solar_system_id = $info->solar_system_id;
$structure->solary_system_name = $solarName; $structure->solary_system_name = $solarName;
if(isset($info['type_id'])) { if(isset($info->type_id)) {
$structure->type_id = $info['type_id']; $structure->type_id = $info->type_id;
} }
$structure->corporation_id = $structure['corporation_id']; $structure->corporation_id = $structure->corporation_id;
if(isset($structures['services'])) { if(isset($structures->services)) {
$structure->services = true; $structure->services = true;
} else { } else {
$structure->services = false; $structure->services = false;
} }
if(isset($structure['state_timer_start'])) { if(isset($structure->state_timer_start)) {
$structure->state_timer_start = $this->DecodeDate($structure['state_timer_start']); $structure->state_timer_start = $this->DecodeDate($structure->state_timer_start);
} }
if(isset($structure['state_timer_end'])) { if(isset($structure->state_timer_end)) {
$structure->state_timer_end = $this->DecodeDate($structure['state_timer_end']); $structure->state_timer_end = $this->DecodeDate($structure->state_timer_end);
} }
if(isset($structure['fuel_expires'])) { if(isset($structure->fuel_expires)) {
$structure->fuel_expires = $structure['fuel_expires']; $structure->fuel_expires = $structure->fuel_expires;
} }
$structure->profile_id = $structure['profile_id']; $structure->profile_id = $structure->profile_id;
$structure->position_x = $info['position']['x']; $structure->position_x = $info->position->x;
$structure->position_y = $info['position']['y']; $structure->position_y = $info->position->y;
$structure->position_z = $info['position']['z']; $structure->position_z = $info->position->z;
if(isset($structure['next_reinforce_apply'])) { if(isset($structure->next_reinforce_apply)) {
$structure->next_reinforce_apply = $structure['next_reinforce_apply']; $structure->next_reinforce_apply = $structure->next_reinforce_apply;
} }
if(isset($structure['next_reinforce_hour'])) { if(isset($structure->next_reinforce_hour)) {
$structure->next_reinforce_hour = $structure['next_reinforce_hour']; $structure->next_reinforce_hour = $structure->next_reinforce_hour;
} }
if(isset($structure['next_reinforce_weekday'])) { if(isset($structure->next_reinforce_weekday)) {
$structure->next_reinforce_weekday = $structure['next_reinforce_weekday']; $structure->next_reinforce_weekday = $structure->next_reinforce_weekday;
} }
$structure->reinforce_hour = $structure['reinforce_hour']; $structure->reinforce_hour = $structure->reinforce_hour;
if(isset($structure['reinforce_weekday'])) { if(isset($structure->reinforce_weekday)) {
$structure->reinforce_weekday = $structure['reinforce_weekday']; $structure->reinforce_weekday = $structure->reinforce_weekday;
} }
if(isset($structure['unanchors_at'])) { if(isset($structure->unanchors_at)) {
$structure->unanchors_at = $structure['unanchors_at']; $structure->unanchors_at = $structure->unanchors_at;
} }
//If we set the structure services to true, let's save the services //If we set the structure services to true, let's save the services
if($structure->services == true) { if($structure->services == true) {
$this->StorestructureServices($structure['services'], $structure['structure_id']); $this->StorestructureServices($structure->services, $structure->structure_id);
} }
//Save the database record //Save the database record
@@ -233,21 +233,21 @@ class ProcessStructureJob implements ShouldQueue
//Find the structure id and the name of the service to see if it exists //Find the structure id and the name of the service to see if it exists
$found = Service::where([ $found = Service::where([
'structure_id' => $structureId, 'structure_id' => $structureId,
'name' => $service['name'], 'name' => $service->name,
])->get(); ])->get();
if(!$found) { if(!$found) {
$new = new Service; $new = new Service;
$new->structure_id = $structureId; $new->structure_id = $structureId;
$new->name = $service['name']; $new->name = $service->name;
$new->state = $service['state']; $new->state = $service->state;
$new->save(); $new->save();
} else { } else {
Service::where([ Service::where([
'structure_id' => $structureId, 'structure_id' => $structureId,
'name' => $service['name'], 'name' => $service->name,
])->update([ ])->update([
'state' => $service['state'], 'state' => $service->state,
]); ]);
} }