今日私は次のエラーを修正しようとしています。ララベルでの私の関係の授業が存在しないという奇妙な理由を教えてくれますか?なぜコードが完全にうまく見えるのかわかりません。クラスはlaravelで見つかりませんか?
それが起こっているClass 'App\Database\Website\Roleplay\GovermentRole' not found
:
{{ $governmentMember->government_role->government_title }}
全コード:ここで
@if ($higherGovernment->count() > 0)
@foreach ($higherGovernment as $governmentMember)
<div class="col-md-10">
<div class="col-md-12" style="margin-left:-40px;">
<div class="col-md-1" style="margin-top:-16px;"><img src="http://mywebsite.com/images/get_character_look.php?look={{ $governmentMember->user->look }}&size=b&direction=3&head_direction=3"></div>
<div class="col-md-9" style="margin-left:40px;">
<h4>{{ $governmentMember->government_role->government_title }}<small>The Crown</small></h4>
<p><font color="#aaa">Department here</font></p><br>
</div>
</div>
</div>
@endforeach
@else
There are currently no candigates working in this category.
@endif
は$ governmentMemberがのインスタンスである私のイメージプレイスタットクラス、次のとおりです。
<?php
namespace App\Database\Website\User;
use Eloquent;
class Roleplay extends Eloquent
{
protected $primaryKey = 'id';
protected $table = 'srp_user_statistics';
public $timestamps = false;
protected $fillable = [];
public function user()
{
return $this->belongsTo('App\Database\Website\User\Player', 'user_id', 'id');
}
public function government_role()
{
return $this->belongsTo('App\Database\Website\Roleplay\GovermentRole', 'government_id');
}
}
を
ここは私のGovernmentRoleクラスです:ここで
<?php
namespace App\Database\Website\Roleplay;
use Eloquent;
class GovernmentRole extends Eloquent
{
protected $primaryKey = 'id';
protected $table = 'srp_government_roles';
public $timestamps = false;
protected $fillable = [];
public function stats(){
return $this->hasMany('App\Database\Website\User\Roleplay', 'government_id');
}
}
は、ブレード・ページ用のコントローラです:
<?php
namespace App\Http\Controllers\Frontend\User;
use Auth;
use Cache;
use Illuminate\Http\Request;
use App\Database\Website\User\Roleplay;
use App\Database\Website\Roleplay\GovernmentRole;
use App\Database\Website\Roleplay\Life\LifeEvents;
class GovernmentController
{
public function getView()
{
$royalty = Cache::remember('government.royalty', 1, function() {
return GovernmentRole::where('government_type', 'royalty')->first()->stats;
});
$higherGovernment = Cache::remember('government.higher_government', 1, function() {
return GovernmentRole::where('government_type', 'higher_government')->first()->stats;
});
$seniorGovernment = Cache::remember('government.senior_government', 1, function() {
return GovernmentRole::where('government_type', 'senior_ministers')->first()->stats;
});
$juniorGovernment = Cache::remember('government.junior_government', 1, function() {
return GovernmentRole::where('government_type', 'junior_ministers')->first()->stats;
});
return view('frontend.community.government', compact('juniorGovernment', 'seniorGovernment', 'higherGovernment', 'royalty'));
}
}
ファイルが正しいフォルダに置かれていますか? – tyteen4a03