today I am facing a problem with Laravel. What I want to do is get every 'stat' value for every record where government_type = higher_government. By the way, I am different types, but this is just one of many.
$higherGovernment = Cache::remember('government.higher_government', 1, function() {
return GovernmentRole::where('government_type', 'higher_government')->first()->stats;
});
How can I get all the stats for all types instead of just calling ->first() ?
I have tried removing the ->first() but it doesn't do anything except give me this error:
Undefined property: Illuminate\Database\Eloquent\Builder::$stats
stats is a relationship by the way:
public function stats(){
return $this->hasMany('App\Database\Website\User\Roleplay', 'government_id');
}