Пример #1
0
 public function getListForSelects()
 {
     $dragonList = [];
     foreach (Dragon::with('dragonType')->get() as $dragon) {
         $dragonList[$dragon->id] = $dragon->getPresenter()->fullName;
     }
     asort($dragonList);
     return $dragonList;
 }
 public function isUpToDate($dragonID, $level)
 {
     $dragon = Dragon::with('levelUp.data', 'collectTime.data', 'collectRateFish.data', 'collectRateWood.data')->find($dragonID);
     // See if the dragon can collect wood at this level
     if ($dragon->wood_start_level !== null && $dragon->wood_start_level <= $level) {
         // Check there is data and it's up to date
         $woodC = $dragon->collectRateWood->data->where('level', (int) $level)->first();
         if (!$woodC || \OldData::isModelOld($woodC)) {
             return false;
         }
     }
     // See if the dragon can collect fish at this level
     if ($dragon->fish_start_level !== null && $dragon->fish_start_level <= $level) {
         // Check there is data and it's up to date
         $fishC = $dragon->collectRateFish->data->where('level', (int) $level)->first();
         if (!$fishC || \OldData::isModelOld($fishC)) {
             return false;
         }
     }
     // See if the dragon can collect either fish or wood at this level
     if ($this->startCollectingLevel($dragon) !== false && $this->startCollectingLevel($dragon) <= $level) {
         // Check there is data and it's up to date
         $rateC = $dragon->collectTime->data->where('level', (int) $level)->first();
         if (!$rateC || \OldData::isModelOld($rateC)) {
             return false;
         }
     }
     // See if the dragon can collect iron at this level (and the user can see iron details)
     if (Auth::user()->collect_iron && $dragon->iron_start_level !== null && $dragon->iron_start_level <= $level) {
         // Check there is data and it's up to date
         $ironC = $dragon->collectIronData->where('level', (int) $level)->first();
         if (!$ironC || \OldData::isModelOld($ironC)) {
             return false;
         }
     }
     // Get the level up data
     $levelUpData = $dragon->levelUp->data->where('level', (int) $level)->first();
     // Check there is data and it's up to date
     if (!$levelUpData || \OldData::isModelOld($levelUpData)) {
         return false;
     }
     // We've got this far, so we're good.
     return true;
 }
Пример #3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return view('dragon.index')->with('dragons', Dragon::with('dragonType')->get());
 }