【问题标题】:Laravel 5.2 Eloquent not working in godaddy serverLaravel 5.2 Eloquent 在 Godaddy 服务器中不起作用
【发布时间】:2016-12-09 10:13:19
【问题描述】:

我使用 Laravel 5.2 在本地开发了一个网站。所有功能都运行良好。但是当我把它上传到godaddy服务器时,除了雄辩之外,所有功能都在工作。插入、更新、删除所有作品。但在数据库引擎中,它显示的是 MISAM。我在 INNODB 中更改它。但仍然雄辩不工作。是foreign_key约束的问题吗?错误是 eloquent 变量没有获取数据。怎么解决??

错误:

<body>
    <div id="sf-resetcontent" class="sf-reset">
        <h1>Whoops, looks like something went wrong.</h1>
        <h2 class="block_exception clear_fix">
            <span class="exception_counter">1/1</span>
            <span class="exception_title"><abbr title="Symfony\Component\Debug\Exception\FatalErrorException">FatalErrorException</abbr> in <a title="/home/abhaymilestogo/public_html/floorstyler/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php line 797" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">Model.php line 797</a>:</span>
            <span class="exception_message">Class &#039;\App\Model\organization&#039; not found</span>
        </h2>
        <div class="block">
            <ol class="traces list_exception">
                <li> in <a title="/home/abhaymilestogo/public_html/floorstyler/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php line 797" ondblclick="var f=this.innerHTML;this.innerHTML=this.title;this.title=f;">Model.php line 797</a></li>
            </ol>
        </div>
    </div>
</body>

agent.blade.php

<tr>
    <th>{{$agency['id']}}</th>
    <th>{{$agency['name']}}</th>
    <th>{{$agency->organization->name}}</th>
    <th>{{$agency['status']}}</th>
    <th>{{$agency['updated_at']}}</th>
    <th>{{$agency['created_at']}}</th>
    <th>
        <a style="font-size: medium;" class="fa fa-pencil-square-o" href="agency/edit/{{$agency['name']}}/{{Crypt::encrypt($agency['id'])}}"></a>

        <a style="font-size: medium;" class="fa fa-trash-o" id="{{Crypt::encrypt($agency['id'])}}"></a>
        @if($agency['status'] == 'ALIVE')
            <a style="font-size: medium;" class="fa fa-times" id="{{Crypt::encrypt($agency['id'])}}"></a>
        @else
            <a style="font-size: medium;" class="fa fa-check" id="{{Crypt::encrypt($agency['id'])}}"></a>
        @endif

    </th>
</tr>
@endforeach

问题出在 {{$agency->organization->name}}

【问题讨论】:

  • 显示有错误吗?你检查错误日志了吗?您是否正确设置了数据库?
  • 是的。我认为数据库设置是正确的。但不确定外键是用MYISAM引擎初始化的表。后来我把它改成了INNODB。错误:eeb31122066c28d05a0d3e03d88967b5c2d171dd.php 第 51 行中的 ErrorException:尝试获取非对象的属性(查看:/home/abhaymilestogo/public_html/floorstyler/resources/views/agency.blade.php)此错误仅发生在一个包含雄辩的功能。如果我将其删除,则不会显示错误。
  • 在您的问题中显示您的agencyorganization 模型。
  • 你是导入本地db,还是你的数据库有数据?

标签: laravel eloquent laravel-5.2 godaddy-api


【解决方案1】:

错误清楚地表明 Class \App\Model\organization not found。

请检查您是否在模型类“组织”中定义了命名空间,并验证您指定的路径是否正确。

此外,最好始终以首字母大写来命名类。

如果这不能解决错误,请发布文件 Agency.blade.php。

【讨论】:

  • 是的,它是绝对正确的,它在我的本地机器上工作。我正在上传 agent.blade.php 代码。问题出在哪里。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多