简体   繁体   English

Laravel-未找到类'App \\ Http \\ Controllers \\ Object'

[英]Laravel - Class 'App\Http\Controllers\Object' not found

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: 这是来自以下位置的Operators.php控制器:

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. 我通常能够解决这些问题(或者我忘记了“使用”之类的东西),但是我无法解决此错误。

Turns out the problem lay in the $mydata = json_decode($response->getBody()->getContents()); 原来问题出在$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. 一旦将$mydata更改$mydata return ,我就设法正确地制作了JSON格式,并使$object数组起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM