diff --git a/app/Http/Controllers/Main/ShowingController.php b/app/Http/Controllers/Main/ShowingController.php index df75349..f3e62f3 100644 --- a/app/Http/Controllers/Main/ShowingController.php +++ b/app/Http/Controllers/Main/ShowingController.php @@ -19,6 +19,10 @@ public function showAllShowings() public function order($id) { + // if not authenticated piss off + if (!auth()->check()) { + return redirect()->route('login'); + } return view('main.order', ['title' => "Order Tickets", 'showing' => \App\Models\Showing::findOrfail($id)]); } } diff --git a/app/Models/User.php b/app/Models/User.php index 0977180..69ed44f 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -104,4 +104,9 @@ public function orders() return $this->hasMany('App\Models\Order', 'user_id', 'user_id'); } + public function address() + { + return $this->hasOne('App\Models\Address', 'address_id', 'address_id'); + } + } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 33b83f5..ab063d1 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -2,7 +2,8 @@ namespace App\Providers; -// use Illuminate\Support\Facades\Gate; +use Laravel\Passport\Passport; +use Illuminate\Support\Facades\Gate; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider @@ -24,7 +25,5 @@ class AuthServiceProvider extends ServiceProvider public function boot() { $this->registerPolicies(); - - // } } diff --git a/app/View/Components/CacheImage.php b/app/View/Components/CacheImage.php index 0eaa153..3a5972b 100644 --- a/app/View/Components/CacheImage.php +++ b/app/View/Components/CacheImage.php @@ -23,7 +23,7 @@ public function handleCache() { if (!\Cache::has($this->src)) { $image = file_get_contents($this->src); - \Cache::put($this->src, $image, 60 * 24 * 7); + \Cache::put($this->src, $image, 60 * 24 * 7); // 1 week } return \Cache::get($this->src); } diff --git a/config/auth.php b/config/auth.php index d8c6cee..e4ad889 100644 --- a/config/auth.php +++ b/config/auth.php @@ -40,6 +40,10 @@ 'driver' => 'session', 'provider' => 'users', ], + 'api' => [ + 'driver' => 'passport', + 'provider' => 'users' + ] ], /* diff --git a/database/migrations/2022_11_22_000000_create_addresses_table.php b/database/migrations/2011_11_22_000000_create_addresses_table.php similarity index 54% rename from database/migrations/2022_11_22_000000_create_addresses_table.php rename to database/migrations/2011_11_22_000000_create_addresses_table.php index 3ec4299..5ecc2a4 100644 --- a/database/migrations/2022_11_22_000000_create_addresses_table.php +++ b/database/migrations/2011_11_22_000000_create_addresses_table.php @@ -15,12 +15,12 @@ public function up() Schema::create('addresses', function (Blueprint $table) { $table->id('address_id'); $table->timestamps(); - $table->addColumn('string', 'address_street', ['length' => 255]); - $table->addColumn('string', 'address_city', ['length' => 255]); - $table->addColumn('string', 'address_state', ['length' => 255]); - $table->addColumn('string', 'address_zip', ['length' => 255]); - $table->addColumn('string', 'address_country', ['length' => 255])->default('Netherlands'); - $table->addColumn('string', 'address_phone', ['length' => 255])->nullable(); + $table->string('address_street', 255); + $table->string('address_city', 255); + $table->string('address_state', 255); + $table->string('address_zip', 255); + $table->string('address_country', 255)->default('Netherlands'); + $table->string('address_phone', 255)->nullable(); }); } diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index bbd9d2e..8a13b6a 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -20,6 +20,7 @@ public function up() $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->enum('role', ['default', 'employee', 'manage', 'admin'])->default('default'); + $table->foreignId('address_id')->nullable()->constrained('addresses', 'address_id')->onDelete('cascade'); $table->rememberToken(); $table->timestamps(); }); diff --git a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php index 8b3b49a..6c81fd2 100644 --- a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php +++ b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php @@ -14,7 +14,7 @@ public function up() { Schema::create('personal_access_tokens', function (Blueprint $table) { - $table->id('personal_access_token_id'); + $table->id(); $table->morphs('tokenable'); $table->string('name'); $table->string('token', 64)->unique(); diff --git a/docker-compose.yml b/docker-compose.yml index 006b328..cf6b9f8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,6 +18,8 @@ services: image: phpmyadmin/phpmyadmin container_name: phpmyadmin restart: always + links: + - mysql ports: - "8080:80" environment: diff --git a/public/css/extra.css b/public/css/main/jumbotron.css similarity index 100% rename from public/css/extra.css rename to public/css/main/jumbotron.css diff --git a/public/css/main.css b/public/css/main/main.css similarity index 100% rename from public/css/main.css rename to public/css/main/main.css diff --git a/public/css/main/movies.css b/public/css/main/movies.css new file mode 100644 index 0000000..ba1eea1 --- /dev/null +++ b/public/css/main/movies.css @@ -0,0 +1 @@ +@import "../manage/movies.css"; diff --git a/public/css/order.css b/public/css/main/order.css similarity index 91% rename from public/css/order.css rename to public/css/main/order.css index fc4fab6..1eae7c0 100644 --- a/public/css/order.css +++ b/public/css/main/order.css @@ -2,8 +2,10 @@ body { /* center with spacing on the left and right*/ margin: 0 auto; width: 100%; - max-width: 1000px; padding: 0 20px 3rem; + + display: grid; + place-content: center; } #seat-chooser { @@ -51,3 +53,7 @@ #summary-dyn .seat .price { margin: 0.5rem; float: right; } + +#order-button { + margin-bottom: 10rem; +} diff --git a/public/css/manage/forms.css b/public/css/manage/forms.css new file mode 100644 index 0000000..e952331 --- /dev/null +++ b/public/css/manage/forms.css @@ -0,0 +1,51 @@ +.form { + display: flex; + flex-direction: column; + margin: 0.5rem 0; + padding: 0.5rem; + background: var(--second-bg); + border-radius: 0.5rem; +} + +.form .form-group { + display: flex; + flex-direction: column; + margin: 0.5rem 0; +} + +.form .form-group label { + margin: 0.5rem 0; +} + +.form .form-group button, +.form .form-group select, +.form .form-group textarea, +.form .form-group input { + padding: 0.5rem; + border-radius: 0.5rem; + background: var(--default-bg); + color: var(--default-text); + outline: none; + border: none; +} + +.form .form-group button:hover, +.form .form-group select:hover, +.form .form-group textarea:hover, +.form .form-group input:hover, +.form .form-group button:focus, +.form .form-group select:focus, +.form .form-group textarea:focus, +.form .form-group input:focus { + filter: brightness(1.5); +} + +form .form-group button { + background: var(--highlight-bg); + color: var(--highlight-text); + cursor: pointer; +} + +form .form-group button:hover { + filter: brightness(1.5); +} diff --git a/public/css/manage.css b/public/css/manage/manage.css similarity index 59% rename from public/css/manage.css rename to public/css/manage/manage.css index 18b85d1..a0c27dc 100644 --- a/public/css/manage.css +++ b/public/css/manage/manage.css @@ -9,6 +9,7 @@ header { align-items: center; width: 100%; z-index: 1; + box-shadow: #111111 0 0 10px; } header span { @@ -91,90 +92,9 @@ .card .big-stat { font-weight: bold; } -#movies { - display: flex; - flex-direction: column; -} - -#movies a { - display: flex; - flex-direction: row; - margin: 0.5rem 0; - padding: 0.5rem; - background: var(--second-bg); - border-radius: 0.5rem; -} - -#movies a img { - width: 10vw; - height: 16vw; - object-fit: cover; - transition: transform 0.5s; -} - -#movies a:hover { - filter: brightness(1.5); -} - -#movies a .details { - display: flex; - flex-direction: column; - margin-left: 1rem; -} /* form */ -.form { - display: flex; - flex-direction: column; - margin: 0.5rem 0; - padding: 0.5rem; - background: var(--second-bg); - border-radius: 0.5rem; -} - -.form .form-group { - display: flex; - flex-direction: column; - margin: 0.5rem 0; -} - -.form .form-group label { - margin: 0.5rem 0; -} - -.form .form-group button, -.form .form-group select, -.form .form-group textarea, -.form .form-group input { - padding: 0.5rem; - border-radius: 0.5rem; - background: var(--default-bg); - color: var(--default-text); - outline: none; - border: none; -} - -.form .form-group button:hover, -.form .form-group select:hover, -.form .form-group textarea:hover, -.form .form-group input:hover, -.form .form-group button:focus, -.form .form-group select:focus, -.form .form-group textarea:focus, -.form .form-group input:focus { - filter: brightness(1.5); -} - -form .form-group button { - background: var(--highlight-bg); - color: var(--highlight-text); - cursor: pointer; -} - -form .form-group button:hover { - filter: brightness(1.5); -} #showings { display: flex; diff --git a/public/css/manage/movies.css b/public/css/manage/movies.css new file mode 100644 index 0000000..7ddf529 --- /dev/null +++ b/public/css/manage/movies.css @@ -0,0 +1,63 @@ +#movie-grid { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + flex-direction: row; + gap: 1rem; +} + +#movie-grid a { + position: relative; +} + +#movie-grid a .details { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + display: grid; + place-content: center; + align-content: center; + background: #000; + opacity: 0; + color: var(--default-text); + transition: all .5s; + + max-height: 100%; + max-width: 100%; +} + +#movie-grid a:hover .details { + opacity: 0.7; +} + +/* --- */ + + +#movie-list { + display: flex; + flex-direction: column; +} + +#movie-list a { + display: flex; + flex-direction: row; + margin: 0.5rem 0; + padding: 0.5rem; + background: var(--second-bg); + border-radius: 0.5rem; +} + +#movie-list a img { + width: 10vw; + height: 16vw; + object-fit: cover; + transition: transform 0.5s; +} + +#movie-list a .details { + display: flex; + flex-direction: column; + margin-left: 1rem; +} diff --git a/public/css/movies.css b/public/css/movies.css deleted file mode 100644 index 232b0c8..0000000 --- a/public/css/movies.css +++ /dev/null @@ -1,31 +0,0 @@ -#movies { - display: flex; - flex-wrap: wrap; - justify-content: space-between; - flex-direction: row; - gap: 1rem; -} - -/* Show .details on top of image */ -#movies a { - position: relative; -} - -#movies a .details { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - display: grid; - place-content: center; - align-content: center; - background: var(--second-bg); - opacity: 0; - color: var(--default-text); - transition: all .5s; -} - -#movies a:hover .details { - opacity: 0.7; -} diff --git a/public/js/order.js b/public/js/order.js index 3bcb429..28f37f0 100644 --- a/public/js/order.js +++ b/public/js/order.js @@ -62,7 +62,7 @@ } ); - window.freq.set('seat-chooser', sc); + window.sc = sc; })(); let total = 0; @@ -84,13 +84,14 @@ document.querySelector('button#order-button').addEventListener('click', (e) => { window.sc.selectedSeats.forEach(seat => { seats.push({ seat: seat.id, - ticket: seat.ticket.id + price: seat.ticket.id, }); }); fetch(`/api/order`, { method: 'POST', headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + document.querySelector('#order-button').getAttribute('data-token') || '' }, body: JSON.stringify({ showing: sc.showingId, @@ -98,7 +99,8 @@ document.querySelector('button#order-button').addEventListener('click', (e) => { }) }).then(res => { if (res.ok) { - window.location = '/order/complete'; + // window.location = '/order/complete'; + console.log('Order placed'); } else { alert('Error placing order'); } diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 9e2c05f..359e1e2 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -8,7 +8,7 @@