Example #1
0
 public function buildRulebook($owner = -1)
 {
     //Build rulebook or retrieve it from the cache.
     $out = Cache::remember('rulebook', 24 * 60, function () {
         $baseRulebook = [];
         $baseRulebook['sects'] = $this->expandSects(RulebookSect::get());
         $baseRulebook['clans'] = $this->expandClans(RulebookClan::get());
         $baseRulebook['rituals'] = $this->sortByGroups(RulebookRitual::whereNull('owner')->get(), "rituals");
         $baseRulebook['backgrounds'] = $this->sortByGroups(RulebookBackground::orderBy('name')->get(), "backgrounds");
         $baseRulebook['disciplines'] = $this->expandDisciplines(RulebookDiscipline::orderBy('name')->get());
         $baseRulebook['natures'] = RulebookNature::get();
         $baseRulebook['abilities'] = $this->sortByGroups(RulebookAbility::where('owner', null)->orderBy('name')->get(), "abilities");
         $baseRulebook["paths"] = $this->expandPaths(RulebookPath::get());
         $baseRulebook["derangements"] = RulebookDerangement::get();
         $baseRulebook['merits'] = $this->sortByGroups(RulebookMerit::orderBy("cost")->get(), "merits");
         $baseRulebook['flaws'] = $this->sortByGroups(RulebookFlaw::orderBy("cost")->get(), "flaws");
         return $baseRulebook;
     });
     if ($owner != -1) {
         $out['custom_abilities'] = RulebookAbility::where('owner', $owner)->get();
         $out['elder_powers'] = RulebookElderPower::where('owner_id', $owner)->get();
         $out['combo_disciplines'] = RulebookComboDiscipline::where('owner_id', $owner)->get();
         $out['custom_rituals'] = RulebookRitual::where('owner', $owner)->get();
     }
     return Response::json($out);
 }