Rezervacije

This commit is contained in:
2024-08-06 14:16:40 +02:00
parent 8d5a410c60
commit 6d5509856f
58 changed files with 1052 additions and 3 deletions

View File

@@ -1,2 +1,5 @@
class Company < ApplicationRecord
has_many :customers, dependent: :destroy
has_many :reservations, dependent: :destroy
has_many :places, dependent: :destroy
end

7
app/models/customer.rb Normal file
View File

@@ -0,0 +1,7 @@
class Customer < ApplicationRecord
belongs_to :company
validates :name, presence: true, uniqueness: { scope: :company_id }
validates :phone, presence: true
validates :company_id, presence: true
end

3
app/models/place.rb Normal file
View File

@@ -0,0 +1,3 @@
class Place < ApplicationRecord
belongs_to :company
end

View File

@@ -0,0 +1,9 @@
class Reservation < ApplicationRecord
belongs_to :company
belongs_to :customer
belongs_to :place
validates :company_id, presence: true
validates :customer_id, presence: true
validates :place_id, presence: true
end