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
|
@ -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
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
|||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Panel;
|
||||
namespace App\Http\Controllers\Profile;
|
||||
|
||||
use App\ChangeEmail;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
@ -32,7 +32,7 @@ class ChangeController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('change');
|
||||
return view('profile.change');
|
||||
}
|
||||
|
||||
public function changePassword(Request $request) {
|
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Panel;
|
||||
namespace App\Http\Controllers\Profile;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AccountController extends Controller
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
|
@ -20,11 +19,13 @@ class AccountController extends Controller
|
|||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('account');
|
||||
return view('profile.home');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Panel;
|
||||
namespace App\Http\Controllers\Profile;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Session;
|
||||
|
@ -25,7 +25,7 @@ class SecurityController extends Controller
|
|||
*
|
||||
* @param Request $request
|
||||
* @param int $page
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
*/
|
||||
|
@ -36,7 +36,7 @@ class SecurityController extends Controller
|
|||
$pages = Session::where('user_id', Auth::id())->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');
|
||||
}
|
||||
|
||||
}
|
54
app/Http/Controllers/RidecountController.php
Normal file
54
app/Http/Controllers/RidecountController.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class RidecountController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->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
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
125
app/Http/Controllers/ShowController.php
Normal file
125
app/Http/Controllers/ShowController.php
Normal file
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Show;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ShowController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->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();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue