Redesign + Fixes
This commit is contained in:
parent
7718ed6c32
commit
7fe8056e35
67 changed files with 1898 additions and 2799 deletions
|
@ -3,161 +3,92 @@ namespace App\Cache;
|
|||
|
||||
class Cache {
|
||||
|
||||
/**
|
||||
* Get Username from API or cache
|
||||
*
|
||||
* @param $uuid
|
||||
* @return bool|mixed The username if success or the UUID if failed
|
||||
*/
|
||||
public static function getUsername($uuid) {
|
||||
if (file_exists(storage_path('app/uuid/'.$uuid.'.json'))) {
|
||||
if(file_exists(storage_path('app/uuid/'.$uuid.'.json'))) {
|
||||
$json = file_get_contents(storage_path('app/uuid/'.$uuid.'.json'));
|
||||
$json = json_decode($json, true);
|
||||
if ((time() - strtotime($json['time'])) > 3600) {
|
||||
$username = self::getUsernameUncached($uuid);
|
||||
if ($username == false) {
|
||||
return $json['name'];
|
||||
} else {
|
||||
$json = [];
|
||||
$json['id'] = $uuid;
|
||||
$json['name'] = $username;
|
||||
self::saveJson($json);
|
||||
if((time() - strtotime($json['time'])) > 3600) {
|
||||
$json = file_get_contents('https://api.mojang.com/user/profiles/'.$uuid.'/names');
|
||||
if(empty($json)) {
|
||||
$json = file_get_contents(storage_path('app/uuid/'.$uuid.'.json'));
|
||||
$json = json_decode($json, true);
|
||||
return $json['name'];
|
||||
}
|
||||
|
||||
$json = json_decode($json, true);
|
||||
if(isset($json['error'])) {
|
||||
$json = file_get_contents(storage_path('app/uuid/'.$uuid.'.json'));
|
||||
$json = json_decode($json, true);
|
||||
return $json['name'];
|
||||
}
|
||||
|
||||
$name = $json[count($json) -1]['name'];
|
||||
$json = [];
|
||||
$json['id'] = $uuid;
|
||||
$json['name'] = $name;
|
||||
self::saveJson($json);
|
||||
return $json['name'];
|
||||
} else {
|
||||
return $json['name'];
|
||||
}
|
||||
} else {
|
||||
$username = self::getUsernameUncached($uuid);
|
||||
if ($username === $uuid) {
|
||||
$json = file_get_contents('https://api.mojang.com/user/profiles/'.$uuid.'/names');
|
||||
if(empty($json))
|
||||
return $uuid;
|
||||
} else {
|
||||
$json = [];
|
||||
$json['id'] = $uuid;
|
||||
$json['name'] = $username;
|
||||
self::saveJson($json);
|
||||
return $json['name'];
|
||||
}
|
||||
|
||||
$json = json_decode($json, true);
|
||||
if(isset($json['error']))
|
||||
return $uuid;
|
||||
|
||||
$name = $json[count($json) -1]['name'];
|
||||
$json = [];
|
||||
$json['id'] = $uuid;
|
||||
$json['name'] = $name;
|
||||
self::saveJson($json);
|
||||
return $json['name'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get UUID from API or cache
|
||||
*
|
||||
* @param $username
|
||||
* @return bool|mixed The UUID if success or the username if failed
|
||||
*/
|
||||
public static function getUUID($username) {
|
||||
foreach(glob(storage_path('app/uuid/*')) as $file) {
|
||||
$json = file_get_contents($file);
|
||||
$json = json_decode($json, true);
|
||||
if($json['name'] !== $username)
|
||||
continue;
|
||||
|
||||
if ($json['name'] !== $username) continue;
|
||||
|
||||
if ((time() - strtotime($json['time'])) > 3600) {
|
||||
$uuid = self::getUUIDUncached($username);
|
||||
if ($uuid == false) {
|
||||
if((time() - strtotime($json['time'])) > 3600) {
|
||||
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/'.$username);
|
||||
if(empty($json)) {
|
||||
unlink(storage_path('app/uuid/'.$file));
|
||||
return $json['name'];
|
||||
} else {
|
||||
$json = [];
|
||||
$json['id'] = $uuid;
|
||||
$json['name'] = $username;
|
||||
self::saveJson($json);
|
||||
return $json['id'];
|
||||
return $username;
|
||||
}
|
||||
|
||||
$json = json_decode($json, true);
|
||||
if(isset($json['error'])) {
|
||||
unlink(storage_path('app/uuid/'.$file));
|
||||
return $username;
|
||||
}
|
||||
|
||||
self::saveJson($json);
|
||||
return $json['id'];
|
||||
} else {
|
||||
return $json['id'];
|
||||
}
|
||||
}
|
||||
|
||||
$uuid = self::getUUIDUncached($username);
|
||||
if ($uuid == false) {
|
||||
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/'.$username);
|
||||
if(empty($json))
|
||||
return $username;
|
||||
} else {
|
||||
$json = [];
|
||||
$json['id'] = $uuid;
|
||||
$json['name'] = $username;
|
||||
self::saveJson($json);
|
||||
return $json['id'];
|
||||
}
|
||||
|
||||
$json = json_decode($json, true);
|
||||
if(isset($json['error']))
|
||||
return $username;
|
||||
|
||||
self::saveJson($json);
|
||||
return $json['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UUID by the username
|
||||
*
|
||||
* @param $username
|
||||
* @return bool|mixed The UUID without dashes, or false if failed
|
||||
*/
|
||||
private static function getUUIDUncached($username) {
|
||||
$profile = self::getProfile($username);
|
||||
if (is_array($profile) and isset($profile['id']))
|
||||
return $profile['id'];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the profile (username & UUID) from the username
|
||||
*
|
||||
* @uses http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time
|
||||
*
|
||||
* @param $username
|
||||
* @return bool|mixed Array with ID and name, or false if failed
|
||||
*/
|
||||
private static function getProfile($username) {
|
||||
if (self::isValidUsername($username)) {
|
||||
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . $username);
|
||||
if (!empty($json)) {
|
||||
$data = json_decode($json, true);
|
||||
if (is_array($data) and !empty($data)) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the username from the UUID
|
||||
*
|
||||
* @uses http://wiki.vg/Mojang_API#UUID_-.3E_Name_history
|
||||
*
|
||||
* @param $uuid
|
||||
* @return bool|mixed Username, or false if failed
|
||||
*/
|
||||
private static function getUsernameUncached($uuid) {
|
||||
if (is_string($uuid)) {
|
||||
$json = file_get_contents('https://api.mojang.com/user/profiles/' . $uuid . '/names');
|
||||
if (!empty($json)) {
|
||||
$data = json_decode($json, true);
|
||||
if (!empty($data) and is_array($data)) {
|
||||
$last = array_pop($data);
|
||||
if (is_array($last) and isset($last['name'])) {
|
||||
return $last['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the username is correct.
|
||||
*
|
||||
* @param $username
|
||||
* @return bool Valid or not
|
||||
*/
|
||||
private static function isValidUsername($username) {
|
||||
return is_string($username) and strlen($username) >= 2 and strlen($username) <= 16 and ctype_alnum(str_replace('_', '', $username));
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the JSON to a file
|
||||
*
|
||||
* @param $json
|
||||
*/
|
||||
private static function saveJson($json) {
|
||||
public static function saveJson($json) {
|
||||
$array = [
|
||||
'id' => $json['id'],
|
||||
'name' => $json['name'],
|
||||
|
|
|
@ -4,26 +4,26 @@ namespace App\Color;
|
|||
class MinecraftColor {
|
||||
|
||||
private static $array = [
|
||||
"&0" => "#333",
|
||||
"&1" => "#2980b9",
|
||||
"&2" => "#27ae60",
|
||||
"&3" => "#01a3a4",
|
||||
"&4" => "#c0392b",
|
||||
"&5" => "#8e44ad",
|
||||
"&6" => "#f39c12",
|
||||
"&7" => "#95a5a6",
|
||||
"&8" => "#7f8c8d",
|
||||
"&9" => "#3498db",
|
||||
"&a" => "#2ecc71",
|
||||
"&b" => "#00d2d3",
|
||||
"&c" => "#e74c3c",
|
||||
"&d" => "#f368e0",
|
||||
"&e" => "#f1c40f",
|
||||
"&f" => "#bdc3c7"
|
||||
"&0" => "#000000",
|
||||
"&1" => "#0000AA",
|
||||
"&2" => "#00AA00",
|
||||
"&3" => "#00AAAA",
|
||||
"&4" => "#AA0000",
|
||||
"&5" => "#AA00AA",
|
||||
"&6" => "#FFAA00",
|
||||
"&7" => "#AAAAAA",
|
||||
"&8" => "#555555",
|
||||
"&9" => "#5555FF",
|
||||
"&a" => "#55FF55",
|
||||
"&b" => "#55FFFF",
|
||||
"&c" => "#FF5555",
|
||||
"&d" => "#FF55FF",
|
||||
"&e" => "#FFFF55",
|
||||
"&f" => "#FFFFFF"
|
||||
];
|
||||
|
||||
private static $none = [
|
||||
"&l", "&m", "&n", "&o", "&r",
|
||||
"&k", "&l", "&m", "&n", "&o", "&r",
|
||||
];
|
||||
|
||||
public static function color($text) {
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use App\Color\MinecraftColor;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
class ControlController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(['auth', 'verified', '2fa']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @param $attraction_id
|
||||
* @param $pin
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index($attraction_id, $pin)
|
||||
{
|
||||
if(!preg_match('/^([0-9]){9}$/', $pin))
|
||||
return Redirect::route('status');
|
||||
|
||||
$data = DB::table('attraction')->select('name')->where('id', '=', $attraction_id)->first();
|
||||
if(empty($data))
|
||||
return Redirect::route('status');
|
||||
|
||||
return view('control')->with([
|
||||
'attraction_id' => $attraction_id,
|
||||
'attraction_name' => MinecraftColor::stripColor( $data->name),
|
||||
'pin' => $pin
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
|
@ -26,8 +26,11 @@ class HomeController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
if(!env('HOME_PAGE', false))
|
||||
return redirect()->route('status');
|
||||
|
||||
return view('home')->with([
|
||||
'message' => ''
|
||||
'message' => \App\Message::orderByDesc('id')->first()
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
class OpenAudioMCController extends Controller
|
||||
{
|
||||
|
@ -30,17 +29,11 @@ class OpenAudioMCController extends Controller
|
|||
if(!filter_var($url, FILTER_VALIDATE_URL))
|
||||
return view('openaudiomc')->with(['type' => 1]);
|
||||
|
||||
$key = explode('/', $url);
|
||||
$key = $key[count($key) - 1];
|
||||
if(!preg_match('/^([a-zA-Z0-9]{8})\-([a-zA-Z0-9]{4})\-([a-zA-Z0-9]{4})\-([a-zA-Z0-9]{4})\-([a-zA-Z0-9]{12})$/', $key))
|
||||
return view('openaudiomc')->with(['type' => 1]);
|
||||
|
||||
$url = str_replace('%UUID%', Auth::user()->fixedUUID(), $url);
|
||||
$result = file_get_contents($url);
|
||||
if(!$this->isJson($result))
|
||||
$json = json_decode($result);
|
||||
if(empty($result) || json_last_error() != JSON_ERROR_NONE)
|
||||
return view('openaudiomc')->with(['type' => 1]);
|
||||
|
||||
$json = json_decode($result);
|
||||
if(isset($json->errors) && !empty($json->errors))
|
||||
return view('openaudiomc')->with(['type' => 2]);
|
||||
|
||||
|
@ -48,23 +41,28 @@ class OpenAudioMCController extends Controller
|
|||
return view('openaudiomc')->with(['type' => 2]);
|
||||
|
||||
$response = $json->response;
|
||||
if(!isset($response->isConnected) || !isset($response->sessionUrl))
|
||||
if(!isset($response->players) || empty($response->players))
|
||||
return view('openaudiomc')->with(['type' => 2]);
|
||||
|
||||
if($response->isConnected)
|
||||
$response = $response->players;
|
||||
|
||||
$uuid = Auth::user()->fixedUUID();
|
||||
$user = null;
|
||||
foreach ($response as $player) {
|
||||
if($player->uuid === $uuid) {
|
||||
$user = $player;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($user))
|
||||
return view('openaudiomc')->with(['type' => 2]);
|
||||
|
||||
if(!isset($user->isConnected) || $user->isConnected)
|
||||
return view('openaudiomc')->with(['type' => 3]);
|
||||
|
||||
$link = $json->response->sessionUrl;
|
||||
header('Location: '.$link);
|
||||
header('Location: '.$user->url);
|
||||
exit;
|
||||
}
|
||||
|
||||
private function isJson($string) {
|
||||
if(empty($string))
|
||||
return false;
|
||||
|
||||
json_decode($string);
|
||||
return (json_last_error() == JSON_ERROR_NONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ class HomeController extends Controller
|
|||
public function index()
|
||||
{
|
||||
$users = User::count();
|
||||
$regions = DB::table('region')->count();
|
||||
$attractions = DB::table('attraction')->where('type', '!=', 'GLOBAL')->count();
|
||||
$shows = Show::count();
|
||||
$regions = DB::table('regions')->count();
|
||||
$attractions = DB::table('attractions')->count();
|
||||
$shows = env('SHOWS', false) ? Show::count() : 0;
|
||||
return view('panel.home')->with([
|
||||
'users' => $users,
|
||||
'regions' => $regions,
|
||||
|
|
111
app/Http/Controllers/Panel/ToolController.php
Normal file
111
app/Http/Controllers/Panel/ToolController.php
Normal file
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Panel;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Show;
|
||||
use App\ShowDate;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ToolController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(['auth', 'verified', '2fa', 'admin']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the operator tool.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function operator()
|
||||
{
|
||||
return view('panel.operator');
|
||||
}
|
||||
|
||||
//Default values for cssTags
|
||||
private $cssDefaults = [
|
||||
'banner' => 'url("../img/banner.png") center center',
|
||||
'bg' => '#f2f2f2',
|
||||
'light' => '#2ecc71',
|
||||
'dark' => "#27ae60",
|
||||
'text' => '#fff',
|
||||
];
|
||||
|
||||
//Tags that can be changed in root.css
|
||||
private $cssTags = [
|
||||
'banner' => 'banner',
|
||||
"bg" => "bg",
|
||||
"light" => "color-light",
|
||||
"dark" => "color-dark",
|
||||
"text" => "color-text",
|
||||
];
|
||||
|
||||
public function css() {
|
||||
$styles = $this->cssDefaults;
|
||||
|
||||
if(file_exists(storage_path('app/public/css.json'))) {
|
||||
$json = file_get_contents(storage_path('app/public/css.json'));
|
||||
$json = json_decode($json);
|
||||
if(json_last_error() != JSON_ERROR_NONE && !empty($json))
|
||||
$styles = $json;
|
||||
}
|
||||
|
||||
return view('panel.css')->with([
|
||||
'styles' => $styles,
|
||||
]);
|
||||
}
|
||||
|
||||
public function cssPost(Request $request) {
|
||||
$rules = [];
|
||||
foreach($this->cssTags as $key => $value)
|
||||
$rules[$key] = ['required'];
|
||||
|
||||
$validator = Validator::make($request->all(), $rules);
|
||||
|
||||
if(!$validator->passes())
|
||||
return Redirect::back()->withErrors($validator->errors());
|
||||
|
||||
$styles = [];
|
||||
foreach($request->all() as $key => $value)
|
||||
if(array_key_exists($key, $this->cssTags))
|
||||
$styles[$key] = $value;
|
||||
|
||||
file_put_contents(storage_path('app/public/css.json'), json_encode($styles));
|
||||
|
||||
$str = ":root {\n";
|
||||
foreach($styles as $key => $value)
|
||||
$str .= "\t--".$this->cssTags[$key].': '.$value.";\n";
|
||||
|
||||
file_put_contents(public_path('assets/css/root.css'), $str.'}');
|
||||
|
||||
return view('panel.css')->with([
|
||||
'styles' => $styles,
|
||||
]);
|
||||
}
|
||||
|
||||
public function cssReset() {
|
||||
$styles = $this->cssDefaults;
|
||||
|
||||
file_put_contents(storage_path('app/public/css.json'), json_encode($styles));
|
||||
|
||||
$str = ":root {\n";
|
||||
foreach($styles as $key => $value)
|
||||
$str .= '--'.$this->cssTags[$key].': '.$value.";\n";
|
||||
|
||||
file_put_contents(public_path('assets/css/root.css'), $str.'}');
|
||||
|
||||
return Redirect::back();
|
||||
}
|
||||
|
||||
}
|
|
@ -35,7 +35,7 @@ class SecurityController extends Controller
|
|||
$tfa = $google2fa->isActivated();
|
||||
$pages = Session::where('user_id', Auth::id())->count();
|
||||
$pages = (int) ceil($pages/10);
|
||||
if($page > $pages)
|
||||
if($page < 1 || ($page > $pages && $page != 1))
|
||||
return redirect()->route('security', ['page' => $pages]);
|
||||
|
||||
$sessions = Session::where('user_id', Auth::id())->where('id', '!=', session()->getId())->skip(($page - 1)*10)->take(($page != 1 ? 10 : 9))->orderBy('last_activity', 'desc')->get();
|
||||
|
|
|
@ -26,26 +26,57 @@ class RidecountController extends Controller
|
|||
*/
|
||||
public function index($attraction_id)
|
||||
{
|
||||
$name = DB::table('attraction')->select('name')->where('id', '=', $attraction_id)->first()->name;
|
||||
$top10 = DB::table(DB::raw('ridecount, (SELECT @row_number:=0) AS t'))->select('uuid', DB::raw('SUM(`count`) AS `count`'), DB::raw('(@row_number:=@row_number + 1) AS `num`'))
|
||||
->where('attractionId', '=', $attraction_id)
|
||||
->whereRaw('YEARWEEK(date, 1) = YEARWEEK(CURDATE(), 1)')
|
||||
->whereRaw('YEAR(date) = YEAR(CURDATE())')
|
||||
->groupBy('uuid')
|
||||
$attraction = DB::table('attractions')->select(['cover','name','status_id'])->where('id', '=', $attraction_id)->first();
|
||||
if(empty($attraction))
|
||||
return redirect()->route('status');
|
||||
|
||||
$type = env('TOP', 1);
|
||||
if($type < 0 || $type > 4)
|
||||
return redirect()->route('status');
|
||||
|
||||
switch ($type) {
|
||||
case 1:
|
||||
$filter = 'week = WEEK(CURDATE(), 1)';
|
||||
break;
|
||||
case 2:
|
||||
$filter = 'month = MONTH(CURDATE())';
|
||||
break;
|
||||
case 3:
|
||||
$filter = 0;
|
||||
break;
|
||||
case 4:
|
||||
$filter = -1;
|
||||
break;
|
||||
default:
|
||||
$filter = 'day = DAYOFYEAR(CURDATE())';
|
||||
break;
|
||||
}
|
||||
|
||||
$top10 = DB::table(DB::raw('ridecounts, (SELECT @row_number:=0) AS t'))->select('uuid', DB::raw('SUM(`count`) AS `count`'), DB::raw('(@row_number:=@row_number + 1) AS `num`'))
|
||||
->where('attraction_id', '=', $attraction_id);
|
||||
|
||||
if(!empty($filter))
|
||||
$top10 = $top10->whereRaw($filter);
|
||||
|
||||
if($filter !== -1)
|
||||
$top10 = $top10->whereRaw('year = YEAR(CURDATE())');
|
||||
|
||||
$top10 = $top10->groupBy('uuid')
|
||||
->orderByDesc('count')
|
||||
->take(10)->get()->all();
|
||||
|
||||
$personal = DB::table('ridecount')
|
||||
->where('attractionId', '=', $attraction_id)
|
||||
->where('uuid', '=', Auth::user()->uuid)
|
||||
$personal = DB::table('ridecounts')
|
||||
->where('attraction_id', '=', $attraction_id)
|
||||
->where('uuid', '=', Auth::user()->fixedUUID())
|
||||
->sum('count');
|
||||
|
||||
$total = DB::table('ridecount')
|
||||
->where('attractionId', '=', $attraction_id)
|
||||
$total = DB::table('ridecounts')
|
||||
->where('attraction_id', '=', $attraction_id)
|
||||
->sum('count');
|
||||
|
||||
$attraction->status = DB::table('states')->where('id', '=', $attraction->status_id)->first();
|
||||
return view('ridecount')->with([
|
||||
'name' => $name,
|
||||
'attraction' => $attraction,
|
||||
'top10' => $top10,
|
||||
'personal' => $personal,
|
||||
'total' => $total
|
||||
|
|
|
@ -29,14 +29,14 @@ class ShowController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$shows = DB::select(DB::raw('SELECT t1.* FROM `shows` AS t1 RIGHT JOIN `show_dates` AS t2 ON t1.`id` = t2.`show_id` WHERE t2.`date` > CURDATE() GROUP BY t1.`id`'));
|
||||
$shows = DB::select(DB::raw('SELECT t1.* FROM `shows` AS t1 RIGHT JOIN `show_dates` AS t2 ON t1.`id` = t2.`show_id` WHERE t2.`date` > CURRENT_TIMESTAMP() GROUP BY t1.`id`'));
|
||||
return view('show')->with([
|
||||
'shows' => $shows
|
||||
]);
|
||||
}
|
||||
|
||||
public function order($show_id) {
|
||||
$show = Show::join('show_dates', 'show_dates.show_id', '=', 'shows.id')->select('shows.*')->where('shows.id', '=', $show_id)->firstOrFail();
|
||||
$show = Show::join('show_dates', 'show_dates.show_id', '=', 'shows.id')->select('shows.*')->where('shows.id', '=', $show_id)->where('show_dates.date', '>', DB::raw('CURRENT_TIMESTAMP()'))->firstOrFail();
|
||||
$dates = $show->getShowDates(Auth::user()->uuid);
|
||||
|
||||
return view('order')->with([
|
||||
|
|
|
@ -19,7 +19,6 @@ class Kernel extends HttpKernel
|
|||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
\App\Http\Middleware\HttpsProtocol::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
||||
class HttpsProtocol
|
||||
{
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (!$request->secure() && in_array(App::environment(), ['stage', 'production']))
|
||||
return redirect()->secure($request->getRequestUri());
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -10,9 +10,9 @@ class Status {
|
|||
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
|
||||
$regions = DB::table('regions')->get()->all();
|
||||
$attractions = DB::table('attractions')->get()->all();
|
||||
$statuses = DB::table('states')->get()->all();
|
||||
|
||||
$data = [];
|
||||
foreach($regions as $region) {
|
||||
|
@ -22,11 +22,14 @@ class Status {
|
|||
|
||||
$status = [];
|
||||
foreach ($statuses as $stat)
|
||||
$status[$stat->statusId] = $stat->statusName;
|
||||
$status[$stat->id] = (object) [
|
||||
"name" => $stat->name,
|
||||
"color" => $stat->color,
|
||||
];
|
||||
|
||||
foreach ($attractions as $attraction) {
|
||||
$region_id = $attraction->region_id;
|
||||
$attraction->status = $status[$attraction->status];
|
||||
$attraction->status = $status[$attraction->status_id];
|
||||
if(array_key_exists($region_id, $data))
|
||||
array_push($data[$region_id]->attractions, $attraction);
|
||||
}
|
||||
|
|
Reference in a new issue