diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Color/MinecraftColor.php b/app/Color/MinecraftColor.php
new file mode 100644
index 0000000..ad07bc5
--- /dev/null
+++ b/app/Color/MinecraftColor.php
@@ -0,0 +1,52 @@
+ "#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"
+ ];
+
+ private static $none = [
+ "&l", "&m", "&n", "&o", "&r",
+ ];
+
+ public static function color($text) {
+ foreach(self::$array as $key => $value) {
+ $str = str_replace($key, $value, $text);
+ if($str !== $text) {
+ return $value;
+ }
+ }
+
+ return "";
+ }
+
+ public static function stripColor($text) {
+ foreach(self::$array as $key => $value) {
+ $text = str_replace($key, "", $text);
+ }
+
+ foreach(self::$none as $key) {
+ $text = str_replace($key, "", $text);
+ }
+
+ return $text;
+ }
+
+}
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index 6fab8cb..d399e23 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -2,12 +2,8 @@
namespace App\Http\Controllers;
-use App\Http\Controllers\Controller;
-use App\Order;
-use App\OrderedProject;
-use App\Project;
-use App\Status;
-use App\Utils\Numbers;
+
+use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
class HomeController extends Controller
@@ -34,6 +30,21 @@ class HomeController extends Controller
]);
}
+ public function status()
+ {
+ return view('status');
+ }
+ public function photo() {
+ $photos = DB::table('actionfotos')
+ ->join('attraction', 'attraction.id', '=', 'actionfotos.ride')
+ ->where('actionfotos.uuid', '=', Auth::user()->uuid)
+ ->select('actionfotos.base64')
+ ->get()->all();
+
+ return view('photo', [
+ 'photos' => $photos
+ ]);
+ }
}
diff --git a/app/Http/Controllers/Panel/HomeController.php b/app/Http/Controllers/Panel/HomeController.php
index 0f15ec0..d5288e3 100644
--- a/app/Http/Controllers/Panel/HomeController.php
+++ b/app/Http/Controllers/Panel/HomeController.php
@@ -3,12 +3,6 @@
namespace App\Http\Controllers\Panel;
use App\Http\Controllers\Controller;
-use App\Order;
-use App\OrderedProject;
-use App\Project;
-use App\Status;
-use App\Utils\Numbers;
-use Illuminate\Support\Facades\DB;
class HomeController extends Controller
{
@@ -34,6 +28,4 @@ class HomeController extends Controller
]);
}
-
-
}
diff --git a/app/Http/Controllers/ChangeController.php b/app/Http/Controllers/Profile/ChangeController.php
similarity index 97%
rename from app/Http/Controllers/ChangeController.php
rename to app/Http/Controllers/Profile/ChangeController.php
index a8942fe..e5204f1 100644
--- a/app/Http/Controllers/ChangeController.php
+++ b/app/Http/Controllers/Profile/ChangeController.php
@@ -1,6 +1,6 @@
count();
$pages = (int) ceil($pages/10);
if($page > $pages)
- return redirect()->route('security', ['page' => $pages]);
+ return redirect()->route('profile.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();
$array = ['TFA' => $tfa, 'pages' => $pages, 'page' => $page, 'sessions' => $sessions, 'agent' => new Agent()];
@@ -58,19 +58,19 @@ class SecurityController extends Controller
);
$array['QRCode'] = $QR;
- return view('security')->with($array);
+ return view('profile.security')->with($array);
}
- return view('security')->with($array);
+ return view('profile.security')->with($array);
}
public function session($id)
{
if(session()->getId() === $id)
- return redirect()->route('security');
+ return redirect()->route('profile.security');
Session::where(['id' => $id, 'user_id' => Auth::id()])->forceDelete();
- return redirect()->route('security');
+ return redirect()->route('profile.security');
}
}
diff --git a/app/Http/Controllers/RidecountController.php b/app/Http/Controllers/RidecountController.php
new file mode 100644
index 0000000..5d9aa0a
--- /dev/null
+++ b/app/Http/Controllers/RidecountController.php
@@ -0,0 +1,54 @@
+middleware(['auth', 'verified', '2fa']);
+ }
+
+ /**
+ * Show the application dashboard.
+ *
+ * @param $attraction_id
+ * @return \Illuminate\Contracts\Support\Renderable
+ */
+ 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)')
+ ->groupBy('uuid')
+ ->orderByDesc('count')
+ ->take(10)->get()->all();
+
+ $personal = DB::table('ridecount')
+ ->where('attractionId', '=', $attraction_id)
+ ->where('uuid', '=', Auth::user()->uuid)
+ ->sum('count');
+
+ $total = DB::table('ridecount')
+ ->where('attractionId', '=', $attraction_id)
+ ->sum('count');
+
+ return view('ridecount')->with([
+ 'name' => $name,
+ 'top10' => $top10,
+ 'personal' => $personal,
+ 'total' => $total
+ ]);
+ }
+
+}
diff --git a/app/Http/Controllers/ShowController.php b/app/Http/Controllers/ShowController.php
new file mode 100644
index 0000000..6391a61
--- /dev/null
+++ b/app/Http/Controllers/ShowController.php
@@ -0,0 +1,125 @@
+middleware(['auth', 'verified', '2fa']);
+ }
+
+ /**
+ * Show the application dashboard.
+ *
+ * @return \Illuminate\Contracts\Support\Renderable
+ */
+ public function index()
+ {
+ $shows = Show::join('show_dates', 'show_dates.show_id', '=', 'shows.id')
+ ->whereRaw('`show_dates`.`date` > CURDATE()')
+ ->select('shows.*')->get()->all();
+
+ $data = [];
+ foreach($shows as $show)
+ if(!empty($show->getShowDates(Auth::user()->uuid)))
+ array_push($data, $show);
+
+ 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();
+ $dates = $show->getShowDates(Auth::user()->uuid);
+
+ return view('order')->with([
+ 'show' => $show,
+ 'dates' => $dates
+ ]);
+ }
+
+ public function makeOrder(Request $request) {
+ if(!$request->has('id')) {
+ session()->flash('error', 'Incorrect form data');
+ return Redirect::back();
+ }
+
+ $show = Show::find($request->get('id'));
+ if(empty($show)) {
+ session()->flash('error', 'Incorrect form data');
+ return Redirect::back();
+ }
+
+ $validator = Validator::make($request->all(), [
+ 'id' => ['required', 'numeric'],
+ 'date' => ['required', 'date']
+ ]);
+
+ if(!$validator->passes()) {
+ session()->flash('error', 'Incorrect show date');
+ return Redirect::back();
+ }
+
+ $data = DB::table('show_dates')
+ ->leftJoin('seats', 'seats.date', '=','show_dates.date')
+ ->where('show_dates.date', '=', $request->get('date'))
+ ->where('show_dates.show_id', '=', $show->id)
+ ->select('show_dates.date', DB::raw('COUNT(`seats`.`id`) AS `filled_seats`'), DB::raw('GROUP_CONCAT(`seats`.`uuid`) AS `uuids`'), DB::raw('GROUP_CONCAT(`seats`.`seat`) AS `used_seats`'))
+ ->groupBy('show_dates.date')
+ ->first();
+
+ if(empty($data)) {
+ session()->flash('error', 'Incorrect show date');
+ return Redirect::back();
+ }
+
+ $time = strtotime($request->get('date'));
+ if(strpos($data->uuids, Auth::user()->uuid) !== false) {
+ session()->flash('error', 'You already booked the show on '.date('d-m-Y', $time).' at '.date('H:m', $time));
+ return Redirect::back();
+ }
+
+ if($data->filled_seats >= $show->seats) {
+ session()->flash('error', 'This show is already fully booked on '.date('d-m-Y', $time).' at '.date('H:m', $time));
+ return Redirect::back();
+ }
+
+ $array = [];
+ $seats = explode(',', $data->used_seats);
+ for($i = 1; $i <= $show->seats; $i++)
+ if(!in_array($i, $seats))
+ array_push($array, $i);
+
+ $result = DB::table('seats')->insert([
+ 'uuid' => Auth::user()->uuid,
+ 'show_id' => $show->id,
+ 'seat' => $array[array_rand($array)],
+ 'voucher' => Str::random(8),
+ 'date' => $request->date
+ ]);
+
+ if(empty($result)) {
+ session()->flash('error', 'Unable to book show on '.date('d-m-Y', $time).' at '.date('H:m', $time));
+ return Redirect::back();
+ }
+
+ session()->flash('success', 'Successfully reserved seat for show on '.date('d-m-Y', $time).' at '.date('H:m', $time));
+ return Redirect::back();
+ }
+
+}
diff --git a/app/Show.php b/app/Show.php
new file mode 100644
index 0000000..d07d885
--- /dev/null
+++ b/app/Show.php
@@ -0,0 +1,55 @@
+data !== null)
+ return $this->data;
+
+ $data = DB::table('show_dates')
+ ->leftJoin('seats', 'seats.date', '=','show_dates.date')
+ ->havingRaw('COUNT(`seats`.`id`) < '.$this->seats)
+ ->whereRaw('`show_dates`.`date` > CURDATE()')
+ ->where('show_dates.show_id', '=', $this->id)
+ ->select('show_dates.date', DB::raw('COUNT(`seats`.`id`) AS `filled_seats`'))
+ ->groupBy('show_dates.date');
+
+ if($uuid !== null)
+ $data = $data->where('seats.uuid', '!=', $uuid);
+
+ $data = $data->get()->all();
+ $dates = [];
+ foreach ($data as $row)
+ array_push($dates, [
+ 'date' => $row->date,
+ 'free_seats' => $this->seats - $row->filled_seats
+ ]);
+
+ $this->data = $dates;
+ return $dates;
+ }
+
+}
diff --git a/app/Status.php b/app/Status.php
new file mode 100644
index 0000000..a64b73a
--- /dev/null
+++ b/app/Status.php
@@ -0,0 +1,44 @@
+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;
+ }
+
+}
diff --git a/app/User.php b/app/User.php
index fb2f8c4..6452d4a 100644
--- a/app/User.php
+++ b/app/User.php
@@ -51,6 +51,37 @@ class User extends Authenticatable implements MustVerifyEmail
return $username;
}
+ private $shows = null;
+ public function hasShows() {
+ if($this->shows !== null)
+ return true;
+
+ $shows = Show::join('seats', 'seats.show_id', '=', 'shows.id')
+ ->select([
+ 'shows.title', 'shows.description', 'shows.image', 'seats.*'
+ ])
+ ->where('seats.uuid', '=', $this->uuid)
+ ->where('seats.date', '>', 'CURRENT_TIMESTAMP()')
+ ->get()->all();
+ $this->shows = $shows;
+ return !empty($shows);
+ }
+
+ public function getShows() {
+ if($this->shows !== null)
+ return $this->shows;
+
+ $shows = Show::join('seats', 'seats.show_id', '=', 'shows.id')
+ ->select([
+ 'shows.title', 'shows.description', 'shows.image', 'seats.*'
+ ])
+ ->where('seats.uuid', '=', $this->uuid)
+ ->where('seats.date', '>', 'CURRENT_TIMESTAMP()')
+ ->get()->all();
+ $this->shows = $shows;
+ return $shows;
+ }
+
public function photo() {
return 'https://crafatar.com/avatars/'.$this->uuid.'?overlay';
}
diff --git a/database/migrations/2019_09_20_141811_create_seats_table.php b/database/migrations/2019_09_20_141811_create_seats_table.php
new file mode 100644
index 0000000..9a7cad1
--- /dev/null
+++ b/database/migrations/2019_09_20_141811_create_seats_table.php
@@ -0,0 +1,36 @@
+bigIncrements('id');
+ $table->bigInteger('show_id');
+ $table->string('uuid');
+ $table->integer('seat');
+ $table->string('voucher');
+ $table->timestamp('date');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('seats');
+ }
+}
diff --git a/database/migrations/2019_09_20_141811_create_show_dates_table.php b/database/migrations/2019_09_20_141811_create_show_dates_table.php
new file mode 100644
index 0000000..109b0f4
--- /dev/null
+++ b/database/migrations/2019_09_20_141811_create_show_dates_table.php
@@ -0,0 +1,33 @@
+bigIncrements('id');
+ $table->bigInteger('show_id');
+ $table->timestamp('date');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('show_dates');
+ }
+}
diff --git a/database/migrations/2019_09_20_141811_create_shows_table.php b/database/migrations/2019_09_20_141811_create_shows_table.php
new file mode 100644
index 0000000..42b99f2
--- /dev/null
+++ b/database/migrations/2019_09_20_141811_create_shows_table.php
@@ -0,0 +1,37 @@
+bigIncrements('id');
+ $table->string('title');
+ $table->text('description');
+ $table->string('price');
+ $table->string('vault_price');
+ $table->integer('seats');
+ $table->string('image');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('shows');
+ }
+}
diff --git a/public/assets/css/skin.css b/public/assets/css/skin.css
index 24f9ee9..4749afd 100644
--- a/public/assets/css/skin.css
+++ b/public/assets/css/skin.css
@@ -255,25 +255,6 @@ th.ip, td.ip {
width: 335px;
}
-code {
- background-color: #eef1f6;
- color: #596981;
- border-radius: 3px;
- padding: 3px;
- line-height: 1.4;
- font-size: 85%;
- border: 1px solid rgba(0, 0, 0, .1);
- display: block;
- width: 335px;
- text-align: right;
- margin: 0;
-}
-
-code i {
- float: left;
- margin: 3px;
-}
-
.role, .project-status {
font-weight: 700;
padding: 5px;
diff --git a/public/assets/css/style.css b/public/assets/css/style.css
index 7b2e443..c91fc5f 100644
--- a/public/assets/css/style.css
+++ b/public/assets/css/style.css
@@ -411,3 +411,45 @@ iframe {
border: 2px solid #fff;
border-radius: 5px;
}
+
+code {
+ background-color: #eef1f6;
+ color: #596981;
+ border-radius: 3px;
+ padding: 3px;
+ line-height: 1.4;
+ font-size: 85%;
+ border: 1px solid rgba(0, 0, 0, .1);
+ display: block;
+ width: 335px;
+ text-align: right;
+ margin: 0;
+}
+
+code i {
+ float: left;
+ margin: 3px;
+}
+
+.pagination li.active a {
+ background-color: #2ecc71;
+ border-color: transparent;
+}
+
+.status, .attraction {
+ font-weight: 900;
+ color: #fff;
+}
+
+.status {
+ padding: 5px;
+ border-radius: 3px;
+ text-align: center;
+}
+
+.actionfoto {
+ width: calc(100% - 4px) !important;
+ height: auto;
+ border: 2px solid #fff;
+ border-radius: 5px;
+}
diff --git a/public/assets/js/core.js b/public/assets/js/core.js
index 17ff5d7..1e2d55a 100644
--- a/public/assets/js/core.js
+++ b/public/assets/js/core.js
@@ -75,4 +75,4 @@ function closeAllSelect(elmnt) {
}
}
-document.addEventListener("click", closeAllSelect);
\ No newline at end of file
+document.addEventListener("click", closeAllSelect);
diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php
index ed55d62..e1ea752 100644
--- a/resources/views/home.blade.php
+++ b/resources/views/home.blade.php
@@ -3,14 +3,17 @@
@section('navigation')