Added Shows, ActionFoto's and Attraction Status
This commit is contained in:
parent
b105bd7db7
commit
ad320963fc
30 changed files with 1190 additions and 503 deletions
44
app/Status.php
Normal file
44
app/Status.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Status {
|
||||
|
||||
private static $data = null;
|
||||
public static function loadData() {
|
||||
if(self::$data !== null)
|
||||
return self::$data;
|
||||
|
||||
$regions = DB::table('region')->get()->all();
|
||||
$attractions = DB::table('attraction')->select(['id', 'name', 'status', 'region_id'])->where('status', '!=', 'GLOBAL')->get()->all();
|
||||
$statuses = DB::table('status')->get()->all(); //TODO
|
||||
|
||||
$data = [];
|
||||
foreach($regions as $region) {
|
||||
$region->attractions = [];
|
||||
$data[$region->id] = $region;
|
||||
}
|
||||
|
||||
$status = [];
|
||||
foreach ($statuses as $stat)
|
||||
$status[$stat->statusId] = $stat->statusName;
|
||||
|
||||
foreach ($attractions as $attraction) {
|
||||
$region_id = $attraction->region_id;
|
||||
$attraction->status = $status[$attraction->status];
|
||||
if(array_key_exists($region_id, $data))
|
||||
array_push($data[$region_id]->attractions, $attraction);
|
||||
}
|
||||
|
||||
$temp = $data;
|
||||
$data = [];
|
||||
foreach ($temp as $key => $value)
|
||||
if(!empty($value->attractions))
|
||||
array_push($data, $value);
|
||||
|
||||
self::$data = $data;
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue