Initial Commit; base feats
This commit is contained in:
commit
9732135e90
137 changed files with 13856 additions and 0 deletions
33
app/Models/Address.php
Normal file
33
app/Models/Address.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Address extends Model
|
||||
{
|
||||
|
||||
protected $table = 'addresses';
|
||||
protected $primaryKey = 'address_id';
|
||||
public $timestamps = false;
|
||||
protected $fillable = [
|
||||
'address_street',
|
||||
'address_city',
|
||||
'address_state',
|
||||
'address_zip',
|
||||
'address_country',
|
||||
'user_id', // to whom does this address belong?
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
}
|
37
app/Models/Movie.php
Normal file
37
app/Models/Movie.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Movie extends Model
|
||||
{
|
||||
|
||||
protected $table = 'movies';
|
||||
protected $primaryKey = 'movie_id';
|
||||
public $timestamps = false;
|
||||
protected $fillable = [
|
||||
'movie_name',
|
||||
'movie_description',
|
||||
'movie_year',
|
||||
'movie_image',
|
||||
'user_id', // who added the movie?
|
||||
'genre_id', // which genre is the movie?
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function genre()
|
||||
{
|
||||
return $this->belongsTo(MovieGenre::class, 'genre_id', 'genre_id');
|
||||
}
|
||||
|
||||
public function showings()
|
||||
{
|
||||
return $this->hasMany(Showing::class, 'movie_id', 'movie_id');
|
||||
}
|
||||
|
||||
}
|
21
app/Models/MovieGenre.php
Normal file
21
app/Models/MovieGenre.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MovieGenre extends Model
|
||||
{
|
||||
protected $table = 'genres';
|
||||
protected $primaryKey = 'genre_id';
|
||||
public $timestamps = false;
|
||||
protected $fillable = [
|
||||
'genre_name',
|
||||
];
|
||||
|
||||
public function movies()
|
||||
{
|
||||
return $this->belongsToMany(Movie::class, 'movie_genres', 'genre_id', 'movie_id');
|
||||
}
|
||||
|
||||
}
|
46
app/Models/Order.php
Normal file
46
app/Models/Order.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
// An order has many tickets, can have two addresses, and belongs to a user
|
||||
|
||||
protected $table = 'orders';
|
||||
protected $primaryKey = 'order_id';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'order_number',
|
||||
'order_status',
|
||||
'billing_address_id',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id', 'user_id');
|
||||
}
|
||||
|
||||
public function billingAddress()
|
||||
{
|
||||
return $this->belongsTo(Address::class, 'billing_address_id', 'address_id');
|
||||
}
|
||||
|
||||
public function shippingAddress()
|
||||
{
|
||||
return $this->belongsTo(Address::class, 'shipping_address_id', 'address_id');
|
||||
}
|
||||
|
||||
public function tickets()
|
||||
{
|
||||
return $this->hasMany(Ticket::class, 'order_id', 'order_id');
|
||||
}
|
||||
|
||||
}
|
27
app/Models/Permission.php
Normal file
27
app/Models/Permission.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Permission extends Model
|
||||
{
|
||||
protected $table = 'permissions';
|
||||
protected $primaryKey = 'permission_id';
|
||||
protected $fillable = [
|
||||
'permission_name',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
// Permissions are linked to users by the user_permissions table
|
||||
// User permissions are linked to users by the user_id and are valid per date
|
||||
public function users()
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'user_permissions', 'permission_id', 'user_id');
|
||||
}
|
||||
|
||||
}
|
39
app/Models/Price.php
Normal file
39
app/Models/Price.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Price extends Model
|
||||
{
|
||||
|
||||
// Price can differ for Adults, Children, Seniors, etc.
|
||||
// Price can default to a base price, but can be overridden by a specific showing.
|
||||
// When creating a showing, there will be rows for each price type.
|
||||
// If for example a childrens price is manually removed, the ticket will not be available for children. (Handy for special events)
|
||||
|
||||
protected $table = 'prices';
|
||||
protected $primaryKey = 'price_id';
|
||||
protected $fillable = [
|
||||
'price_type', // ENUM: (Adult, Child, Senior, loveseat(2 people))
|
||||
'price_value', // Decimal
|
||||
'showing_id', // which showing is this price for?
|
||||
'user_id', // who added the price?
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function showing()
|
||||
{
|
||||
return $this->belongsTo(Showing::class, 'showing_id', 'showing_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id', 'user_id');
|
||||
}
|
||||
|
||||
}
|
39
app/Models/Rating.php
Normal file
39
app/Models/Rating.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Rating extends Model
|
||||
{
|
||||
|
||||
protected $table = 'ratings';
|
||||
protected $primaryKey = 'rating_id';
|
||||
public $timestamps = false;
|
||||
protected $fillable = [
|
||||
'movie_id',
|
||||
'user_id',
|
||||
'rating_value',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'rating_value' => 'decimal:1',
|
||||
];
|
||||
|
||||
public function movie()
|
||||
{
|
||||
return $this->belongsTo(Movie::class, 'movie_id', 'movie_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id', 'user_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
31
app/Models/Room.php
Normal file
31
app/Models/Room.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Room extends Model
|
||||
{
|
||||
|
||||
protected $table = 'rooms';
|
||||
protected $primaryKey = 'room_id';
|
||||
public $timestamps = false;
|
||||
protected $fillable = [
|
||||
'room_name',
|
||||
'room_rows',
|
||||
'room_columns',
|
||||
'user_id', // who added the room?
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function showings()
|
||||
{
|
||||
return $this->hasMany(Showing::class, 'room_id', 'room_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
36
app/Models/Seat.php
Normal file
36
app/Models/Seat.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Seat extends Model
|
||||
{
|
||||
|
||||
protected $table = 'seats';
|
||||
protected $primaryKey = 'seat_id';
|
||||
public $timestamps = false;
|
||||
protected $fillable = [
|
||||
'seat_row',
|
||||
'seat_number',
|
||||
'seat_type', // enum('standard', 'wheelchair', 'loveseat')
|
||||
'room_id',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function room()
|
||||
{
|
||||
return $this->belongsTo(Room::class, 'room_id', 'room_id');
|
||||
}
|
||||
|
||||
public function orders()
|
||||
{
|
||||
return $this->belongsToMany(Order::class, 'order_seats', 'seat_id', 'order_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
39
app/Models/Showing.php
Normal file
39
app/Models/Showing.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Movie Theater Showings
|
||||
*/
|
||||
|
||||
class Showing extends Model
|
||||
{
|
||||
|
||||
protected $table = 'showings';
|
||||
protected $primaryKey = 'showing_id';
|
||||
protected $fillable = [
|
||||
'movie_id',
|
||||
'showing_start',
|
||||
'showing_end',
|
||||
'room_id', // which room is showing the movie?
|
||||
'user_id', // who added the showing?
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function movie()
|
||||
{
|
||||
return $this->belongsTo(Movie::class, 'movie_id', 'movie_id');
|
||||
}
|
||||
|
||||
public function nowPlaying()
|
||||
{
|
||||
return $this->where('showing_start', '>=', now())->get();
|
||||
}
|
||||
|
||||
}
|
37
app/Models/Ticket.php
Normal file
37
app/Models/Ticket.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Ticket extends Model
|
||||
{
|
||||
|
||||
protected $table = 'tickets';
|
||||
protected $primaryKey = 'ticket_id';
|
||||
protected $fillable = [
|
||||
'order_id', // which order is this ticket for?
|
||||
'showing_id', // which showing is this ticket for?
|
||||
'seat_id', // which seat is the ticket for?
|
||||
'price_id', // which price is this ticket?
|
||||
'user_id', // who added the ticket?
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class, 'order_id', 'order_id');
|
||||
}
|
||||
|
||||
public function showing()
|
||||
{
|
||||
return $this->belongsTo(Showing::class, 'showing_id', 'showing_id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
57
app/Models/User.php
Normal file
57
app/Models/User.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
protected $primaryKey = 'user_id';
|
||||
|
||||
// User can be a customer or an employee
|
||||
// If customer, then there'll be a customer_id in the users table
|
||||
// If employee, then there'll be an employee_id in the users table
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'customer_id', // if this is filled, then this user is a customer
|
||||
'employee_id', // if this is filled, then this user is an employee
|
||||
// if both are filled, then this user is both a customer and an employee
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue