mega-commit: migrations, controllers, models, etc.
This commit is contained in:
parent
9732135e90
commit
2c6745e812
70 changed files with 2124 additions and 400 deletions
|
@ -19,6 +19,7 @@ return new class extends Migration
|
|||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->enum('role', ['default', 'employee', 'manage'])->default('default');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id('failed_job_id');
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
|
@ -19,8 +19,8 @@ return new class extends Migration {
|
|||
$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]);
|
||||
$table->foreignId('user_id')->constrained('users', 'user_id');
|
||||
$table->addColumn('string', 'address_country', ['length' => 255])->default('Netherlands');
|
||||
$table->addColumn('string', 'address_phone', ['length' => 255])->nullable();
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('cinemas', function (Blueprint $table) {
|
||||
$table->id('cinema_id');
|
||||
$table->timestamps();
|
||||
$table->string('cinema_name');
|
||||
$table->foreignId('address_id')->constrained('addresses', 'address_id');
|
||||
$table->foreignId('user_id')->constrained('users', 'user_id'); // who created this cinema
|
||||
$table->timestamp('cinema_open')->nullable();
|
||||
$table->timestamp('cinema_close')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('cinemas');
|
||||
}
|
||||
};
|
|
@ -17,6 +17,7 @@ return new class extends Migration
|
|||
$table->id('permission_id');
|
||||
$table->timestamps();
|
||||
$table->addColumn('string', 'permission_name', ['length' => 255]);
|
||||
$table->addColumn('string', 'permission_description', ['length' => 511])->nullable();
|
||||
$table->unique(['permission_name']);
|
||||
});
|
||||
}
|
|
@ -16,10 +16,11 @@ return new class extends Migration
|
|||
Schema::create('rooms', function (Blueprint $table) {
|
||||
$table->id('room_id');
|
||||
$table->timestamps();
|
||||
$table->addColumn('string', 'room_name', ['length' => 255]);
|
||||
$table->addColumn('integer', 'room_rows');
|
||||
$table->addColumn('integer', 'room_columns');
|
||||
$table->unique(['room_name']);
|
||||
$table->string('room_name');
|
||||
$table->integer('room_rows');
|
||||
$table->integer('room_columns');
|
||||
$table->foreignId('cinema_id')->constrained('cinemas', 'cinema_id');
|
||||
$table->foreignId('user_id')->constrained('users', 'user_id'); // who created this room
|
||||
});
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ return new class extends Migration
|
|||
$table->id('showing_id');
|
||||
$table->timestamps();
|
||||
$table->dateTime('showing_start');
|
||||
$table->dateTime('showing_end');
|
||||
// no showing end time, that's implied by the movie length and 10 minutes between showings
|
||||
$table->foreignId('movie_id')->constrained('movies', 'movie_id');
|
||||
$table->foreignId('room_id')->constrained('rooms', 'room_id');
|
||||
$table->foreignId('user_id')->constrained('users', 'user_id');
|
|
@ -18,8 +18,9 @@ return new class extends Migration
|
|||
$table->timestamps();
|
||||
$table->foreignId('permission_id')->constrained('permissions', 'permission_id');
|
||||
$table->foreignId('user_id')->constrained('users', 'user_id');
|
||||
$table->date('user_permission_start');
|
||||
$table->date('user_permission_end');
|
||||
// end can be null to mark indefinitely
|
||||
$table->date('user_permission_start')->useCurrent();
|
||||
$table->date('user_permission_end')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ return new class extends Migration
|
|||
$table->id('order_id');
|
||||
$table->timestamps();
|
||||
$table->addColumn('integer', 'order_number');
|
||||
$table->addColumn('enum', 'order_status', ['values' => ['pending', 'paid', 'cancelled']]);
|
||||
$table->enum('order_status', ['pending', 'paid', 'cancelled']);
|
||||
$table->foreignId('user_id')->constrained('users', 'user_id');
|
||||
$table->foreignId('billing_address_id')->constrained('addresses', 'address_id');
|
||||
$table->unique(['order_number', 'user_id']);
|
||||
|
|
61
database/seeders/CinemaSeeder.php
Normal file
61
database/seeders/CinemaSeeder.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CinemaSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$cinemas = [
|
||||
[
|
||||
'cinema_name' => 'Cinema 1',
|
||||
'cinema_address' => [
|
||||
'address_line_1' => '123 Main Street',
|
||||
'address_line_2' => 'Suite 1',
|
||||
'address_city' => 'City',
|
||||
'address_state' => 'State',
|
||||
'address_zip' => '12345',
|
||||
'address_phone' => '123-456-7890',
|
||||
],
|
||||
],
|
||||
[
|
||||
'cinema_name' => 'Cinema 2',
|
||||
'cinema_address' => [
|
||||
'address_line_1' => '123 Main Street',
|
||||
'address_line_2' => 'Suite 2',
|
||||
'address_city' => 'City',
|
||||
'address_state' => 'State',
|
||||
'address_zip' => '12345',
|
||||
'address_phone' => '123-456-7890',
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
foreach ($cinemas as $cinema) {
|
||||
$c = new \App\Models\Cinema();
|
||||
$c->cinema_name = $cinema['cinema_name'];
|
||||
$c->user_id = 1;
|
||||
|
||||
$a = new \App\Models\Address();
|
||||
$a->address_street = $cinema['cinema_address']['address_line_1'];
|
||||
$a->address_city = $cinema['cinema_address']['address_city'];
|
||||
$a->address_state = $cinema['cinema_address']['address_state'];
|
||||
$a->address_zip = $cinema['cinema_address']['address_zip'];
|
||||
$a->address_phone = $cinema['cinema_address']['address_phone'];
|
||||
$a->save();
|
||||
|
||||
$c->address_id = $a->address_id;
|
||||
$c->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -14,11 +14,14 @@ class DatabaseSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
// \App\Models\User::factory(10)->create();
|
||||
|
||||
// \App\Models\User::factory()->create([
|
||||
// 'name' => 'Test User',
|
||||
// 'email' => 'test@example.com',
|
||||
// ]);
|
||||
$this->call([
|
||||
PermissionSeeder::class,
|
||||
UserSeeder::class,
|
||||
GenreSeeder::class,
|
||||
MovieSeeder::class,
|
||||
CinemaSeeder::class,
|
||||
RoomSeeder::class,
|
||||
ShowingSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
78
database/seeders/GenreSeeder.php
Normal file
78
database/seeders/GenreSeeder.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class GenreSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('genres')->insert([
|
||||
[
|
||||
'genre_name' => 'Action',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Adventure',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Animation',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Comedy',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Crime',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Documentary',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Drama',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Family',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Fantasy',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'History',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Horror',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Music',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Mystery',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Romance',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Science Fiction',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'TV Movie',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Thriller',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'War',
|
||||
],
|
||||
[
|
||||
'genre_name' => 'Western',
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
53
database/seeders/MovieSeeder.php
Normal file
53
database/seeders/MovieSeeder.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Genre;
|
||||
use App\Models\Movie;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class MovieSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$movies = [
|
||||
[
|
||||
'movie_name' => 'Alvin and the Chipmunks',
|
||||
'movie_description' => 'A struggling songwriter named Dave Seville finds success when he comes across a trio of singing chipmunks: mischievous leader Alvin, brainy Simon, and chubby, impressionable Theodore.',
|
||||
'movie_year' => '2007',
|
||||
'movie_age_limit' => 6,
|
||||
'movie_length' => 90,
|
||||
'movie_image' => 'https://www.themoviedb.org/t/p/w600_and_h900_bestv2/vRiB9uvcD0WYp7k2pAeWz9ukpuN.jpg',
|
||||
'genre_id' => (new \App\Models\Genre)->findGenreByName('Comedy')->genre_id,
|
||||
],
|
||||
[
|
||||
'movie_name' => 'Alvin and the Chipmunks: The Squeakquel',
|
||||
'movie_description' => 'Pop sensations Alvin, Simon and Theodore end up in the care of Dave Seville\'s twenty-something nephew Toby. The boys must put aside music super stardom to return to school, and are tasked with saving the school\'s music program by winning the $25,000 prize in a battle of the bands. But the Chipmunks unexpectedly meet their match in three singing chipmunks known as The Chipettes - Brittany, Eleanor and Jeanette. Romantic and musical sparks are ignited when the Chipmunks and Chipettes square off.',
|
||||
'movie_year' => '2009',
|
||||
'movie_age_limit' => 6,
|
||||
'movie_length' => 92,
|
||||
'movie_image' => 'https://www.themoviedb.org/t/p/w600_and_h900_bestv2/8mdPqOga5fty15nXmaNcK1fsNMa.jpg',
|
||||
'genre_id' => (new \App\Models\Genre)->findGenreByName('Comedy')->genre_id,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($movies as $movie) {
|
||||
$m = new Movie();
|
||||
$m->movie_name = $movie['movie_name'];
|
||||
$m->movie_description = $movie['movie_description'];
|
||||
$m->movie_year = $movie['movie_year'];
|
||||
$m->movie_age_limit = $movie['movie_age_limit'];
|
||||
$m->movie_length = $movie['movie_length'];
|
||||
$m->movie_image = $movie['movie_image'];
|
||||
$m->genre_id = $movie['genre_id'];
|
||||
$m->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
104
database/seeders/PermissionSeeder.php
Normal file
104
database/seeders/PermissionSeeder.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PermissionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('permissions')->insert([
|
||||
[
|
||||
'permission_name' => 'READ_GENRES',
|
||||
'permission_description' => 'Read Genres',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'CREATE_GENRES',
|
||||
'permission_description' => 'Create Genres',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'UPDATE_GENRES',
|
||||
'permission_description' => 'Update Genres',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'DELETE_GENRES',
|
||||
'permission_description' => 'Delete Genres',
|
||||
],
|
||||
|
||||
[
|
||||
'permission_name' => 'READ_MOVIES',
|
||||
'permission_description' => 'Read Movies',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'CREATE_MOVIES',
|
||||
'permission_description' => 'Create Movies',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'UPDATE_MOVIES',
|
||||
'permission_description' => 'Update Movies',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'DELETE_MOVIES',
|
||||
'permission_description' => 'Delete Movies',
|
||||
],
|
||||
|
||||
[
|
||||
'permission_name' => 'READ_SHOWINGS',
|
||||
'permission_description' => 'Read Showings',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'CREATE_SHOWINGS',
|
||||
'permission_description' => 'Create Showings',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'UPDATE_SHOWINGS',
|
||||
'permission_description' => 'Update Showings',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'DELETE_SHOWINGS',
|
||||
'permission_description' => 'Delete Showings',
|
||||
],
|
||||
|
||||
[
|
||||
'permission_name' => 'READ_USERS',
|
||||
'permission_description' => 'Read Users',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'CREATE_USERS',
|
||||
'permission_description' => 'Create Users',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'UPDATE_USERS',
|
||||
'permission_description' => 'Update Users',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'DELETE_USERS',
|
||||
'permission_description' => 'Delete Users',
|
||||
],
|
||||
|
||||
[
|
||||
'permission_name' => 'READ_PERMISSIONS',
|
||||
'permission_description' => 'Read Permissions',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'CREATE_PERMISSIONS',
|
||||
'permission_description' => 'Create Permissions',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'UPDATE_PERMISSIONS',
|
||||
'permission_description' => 'Update Permissions',
|
||||
],
|
||||
[
|
||||
'permission_name' => 'DELETE_PERMISSIONS',
|
||||
'permission_description' => 'Delete Permissions',
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
57
database/seeders/RoomSeeder.php
Normal file
57
database/seeders/RoomSeeder.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class RoomSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
foreach (\App\Models\Cinema::all() as $cinema) {
|
||||
$rooms = [
|
||||
[
|
||||
'room_name' => 'Room 1',
|
||||
'room_rows' => 10,
|
||||
'room_columns' => 10,
|
||||
],
|
||||
[
|
||||
'room_name' => 'Room 2',
|
||||
'room_rows' => 10,
|
||||
'room_columns' => 10,
|
||||
],
|
||||
[
|
||||
'room_name' => 'Room 3',
|
||||
'room_rows' => 10,
|
||||
'room_columns' => 10,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($rooms as $room) {
|
||||
$r = new \App\Models\Room();
|
||||
$r->room_name = $room['room_name'];
|
||||
$r->room_rows = $room['room_rows'];
|
||||
$r->room_columns = $room['room_columns'];
|
||||
$r->user_id = 1;
|
||||
$r->cinema_id = $cinema->cinema_id;
|
||||
$r->save();
|
||||
|
||||
for ($row = 1; $row <= $r->room_rows; $row++) {
|
||||
for ($column = 1; $column <= $r->room_columns; $column++) {
|
||||
$s = new \App\Models\Seat();
|
||||
$s->seat_row = $row;
|
||||
$s->seat_column = $column;
|
||||
$s->room_id = $r->room_id;
|
||||
$s->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
50
database/seeders/ShowingSeeder.php
Normal file
50
database/seeders/ShowingSeeder.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class ShowingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// $showStart = <current time + 5days>;
|
||||
|
||||
$showStart = new \DateTime();
|
||||
$showStart->add(new \DateInterval('P5D'));
|
||||
|
||||
foreach (\App\Models\Room::all() as $room) {
|
||||
$showings = [
|
||||
[
|
||||
'showing_start' => $showStart->format('Y-m-d H:i:s'),
|
||||
'showing_end' => $showStart->add(new \DateInterval('PT2H'))->format('Y-m-d H:i:s'),
|
||||
'movie_id' => 1,
|
||||
'room_id' => $room->room_id,
|
||||
],
|
||||
[
|
||||
'showing_start' => $showStart->add(new \DateInterval('PT2H'))->format('Y-m-d H:i:s'),
|
||||
'showing_end' => $showStart->add(new \DateInterval('PT2H'))->format('Y-m-d H:i:s'),
|
||||
'movie_id' => 2,
|
||||
'room_id' => $room->room_id,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($showings as $showing) {
|
||||
$s = new \App\Models\Showing();
|
||||
$s->showing_start = $showing['showing_start'];
|
||||
$s->movie_id = $showing['movie_id'];
|
||||
$s->room_id = $showing['room_id'];
|
||||
$s->user_id = 1;
|
||||
$s->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
26
database/seeders/UserSeeder.php
Normal file
26
database/seeders/UserSeeder.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$user = new User();
|
||||
$user->name = 'system';
|
||||
$user->email = 'sys@local.host';
|
||||
$user->role = 'manage';
|
||||
$user->password = Hash::make('system');
|
||||
$user->save();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue