【发布时间】: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 '\App\Model\organization' 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)此错误仅发生在一个包含雄辩的功能。如果我将其删除,则不会显示错误。
-
在您的问题中显示您的
agency和organization模型。 -
你是导入本地db,还是你的数据库有数据?
标签: laravel eloquent laravel-5.2 godaddy-api