0

I am currently trying to figure out why I get this error:

FatalThrowableError: Class 'App\Http\Controllers\Object' not found in Operators.php line 23

This is the Operators.php controller from where the error is coming from:

public function getOperatorData()
{
    $api = new Client([
    'base_uri' => 'https://www.space-track.org',
    'cookies' => true, 
    ]); $api->post('ajaxauth/login', [
      'form_params' => [
         'identity' => '#', 
         'password' => '#', 
     ],
    ]);
    $response = $api->get('basicspacedata/query/class/satcat/orderby/INTLDES%20desc/limit/1/metadata/false');
    $mydata = json_decode($response->getBody()->getContents());
    $object = new Object();
    $object->intldes = $mydata->INTLDES;
    $object->satname = $mydata->SATNAME;
    $object->save();
    return view('pages/satellite-database', compact('object'));
}

The specific line from where the error comes from is:

$object = new Object();

The line shown above should be creating a new model for querying`in a blade file later on.

I am usually able to solve these (either I forgot the 'use' or something), but I have been unable to solve this error.

15
  • if you need the generic PHP object class use new stdObject() , Object is not a valid class name Commented Jul 27, 2017 at 15:52
  • @apokryfos I tried that but unfortunately it did not work. The error I get with that is Class 'App\Http\Controllers\stdObject' not found Commented Jul 27, 2017 at 15:56
  • Oops, I meant \stdClass Commented Jul 27, 2017 at 15:56
  • try using full namespace to class like new \App\Object Commented Jul 27, 2017 at 15:57
  • I managed to get rid of the error be changing it to $object = new \stdClass();, but now I have a Trying to get property of non-object error. I will see what I can do Commented Jul 27, 2017 at 16:02

1 Answer 1

1

Turns out the problem lay in the $mydata = json_decode($response->getBody()->getContents());.

Once I changed $mydata to return, I managed to make the JSON format properly and get the $object array to work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.