I am developing a roleplay game. Below I have a controller for the government. What I am trying to do is to get a list of the higher government members, senior government members, and the junior government members (these are a different type of government members) for example...
Here is my database structure
- Junior Government would be the Ministers
- Senior Government would be the Secretary of States
- Higher Government would be the Prime Minister and The Crown
I have a table for roleplay statistics called srp_rp_stats
and in there I have a column called government_id
which is meant to match the id in the government
table.
In my government
table, I have an id
field as the primary key, a title
for the government position, and the type
it is. The type
field is an enum, example below...
government_type enum
'higher_government','senior_government','junior_government'
What I want to do below is to get the members of each of the set of governments, but I need to use the government_id
in the rp
table to check that in the government
table the type is actually what I am looking for, how can I do this?
Code:
namespace App\Http\Controllers\Frontend\User;
use Auth;
use Cache;
use Illuminate\Http\Request;
use App\Database\Website\Roleplay\Life\LifeEvents;
class GovernmentController
{
public function getView()
{
$higherGovernment = Cache::remember('government.higher_government', function() {
return Roleplay::get();
});
$seniorGovernment = Cache::Remeber('government.senior_government', function() {
return Roleplay::get();
});
$juniorGovernment = Cache::remember('government.junior_government', function () {
return Roleplay::get();
});
return view('frontend.community.government', compact('higherGovernment', 'seniorGovernment', 'juniorGovernment'));
}
}