room reservation model, controller, seeder and migration files added
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'rooms'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.string('name').notNullable()
|
||||
table.integer('capacity').notNullable()
|
||||
table.string('description').nullable()
|
||||
|
||||
table.timestamp('created_at')
|
||||
table.timestamp('updated_at')
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
|
||||
export default class extends BaseSchema {
|
||||
protected tableName = 'reservations'
|
||||
|
||||
async up() {
|
||||
this.schema.createTable(this.tableName, (table) => {
|
||||
table.increments('id')
|
||||
table.integer('room_id').unsigned().references('id').inTable('rooms').onDelete('CASCADE')
|
||||
table.string('customer_name').notNullable()
|
||||
table.string('customer_phone').notNullable()
|
||||
table.integer('guests_count').notNullable()
|
||||
table.timestamp('starts_at').notNullable()
|
||||
table.timestamp('ends_at').notNullable()
|
||||
table.string('status').defaultTo('confirmed') // confirmed, cancelled
|
||||
table.text('notes').nullable()
|
||||
|
||||
table.timestamp('created_at')
|
||||
table.timestamp('updated_at')
|
||||
})
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.dropTable(this.tableName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { BaseSeeder } from '@adonisjs/lucid/seeders'
|
||||
import Room from '#models/room'
|
||||
|
||||
export default class extends BaseSeeder {
|
||||
async run() {
|
||||
await Room.updateOrCreate(
|
||||
{ name: 'Kisterem' },
|
||||
{
|
||||
name: 'Kisterem',
|
||||
capacity: 20,
|
||||
description: 'Cozy small room for private gatherings.',
|
||||
}
|
||||
)
|
||||
|
||||
await Room.updateOrCreate(
|
||||
{ name: 'Nagyterem' },
|
||||
{
|
||||
name: 'Nagyterem',
|
||||
capacity: 50,
|
||||
description: 'Large hall for big events and weddings.',
|
||||
}
|
||||
)
|
||||
|
||||
await Room.updateOrCreate(
|
||||
{ name: 'Terasz' },
|
||||
{
|
||||
name: 'Terasz',
|
||||
capacity: 30,
|
||||
description: 'Outdoor terrace with a view.',
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user