From 5e722d5a34c95c267894478a4c136e20dc6d342d Mon Sep 17 00:00:00 2001 From: s152484 Date: Sun, 8 Dec 2019 21:55:07 +0100 Subject: [PATCH] PARAG-28 Create models --- paragonik-backend/app/Models/Category.php | 18 ++++++++++++++ paragonik-backend/app/Models/Receipt.php | 25 ++++++++++++++++++++ paragonik-backend/app/Models/ReceiptItem.php | 21 ++++++++++++++++ paragonik-backend/app/Models/Service.php | 13 ++++++++++ paragonik-backend/app/Models/Store.php | 13 ++++++++++ paragonik-backend/app/User.php | 6 +++++ 6 files changed, 96 insertions(+) create mode 100644 paragonik-backend/app/Models/Category.php create mode 100644 paragonik-backend/app/Models/Receipt.php create mode 100644 paragonik-backend/app/Models/ReceiptItem.php create mode 100644 paragonik-backend/app/Models/Service.php create mode 100644 paragonik-backend/app/Models/Store.php diff --git a/paragonik-backend/app/Models/Category.php b/paragonik-backend/app/Models/Category.php new file mode 100644 index 0000000..ac18264 --- /dev/null +++ b/paragonik-backend/app/Models/Category.php @@ -0,0 +1,18 @@ +belongsTo('App\Models\ReceiptItem'); + } + + public function services() + { + return $this->belongsToMany('App\Models\Service', 'categories_services'); + } +} diff --git a/paragonik-backend/app/Models/Receipt.php b/paragonik-backend/app/Models/Receipt.php new file mode 100644 index 0000000..a465184 --- /dev/null +++ b/paragonik-backend/app/Models/Receipt.php @@ -0,0 +1,25 @@ +belongsTo('App\User'); + } + + public function store() + { + return $this->belongsTo('App\User'); + } + + public function receipt_items() + { + return $this->hasMany('App\Models\ReceiptItem'); + } +} diff --git a/paragonik-backend/app/Models/ReceiptItem.php b/paragonik-backend/app/Models/ReceiptItem.php new file mode 100644 index 0000000..d4780c6 --- /dev/null +++ b/paragonik-backend/app/Models/ReceiptItem.php @@ -0,0 +1,21 @@ +belongsTo('App\Models\Receipt'); + } + + public function categories() + { + return $this->hasMany('App\Models\Category'); + } +} diff --git a/paragonik-backend/app/Models/Service.php b/paragonik-backend/app/Models/Service.php new file mode 100644 index 0000000..7fad8fb --- /dev/null +++ b/paragonik-backend/app/Models/Service.php @@ -0,0 +1,13 @@ +belongsToMany('App\Models\Category', 'categories_services'); + } +} diff --git a/paragonik-backend/app/Models/Store.php b/paragonik-backend/app/Models/Store.php new file mode 100644 index 0000000..0aac03c --- /dev/null +++ b/paragonik-backend/app/Models/Store.php @@ -0,0 +1,13 @@ +hasMany('App\Models\Receipt'); + } +} diff --git a/paragonik-backend/app/User.php b/paragonik-backend/app/User.php index faa03c3..373162d 100644 --- a/paragonik-backend/app/User.php +++ b/paragonik-backend/app/User.php @@ -36,4 +36,10 @@ class User extends Authenticatable protected $casts = [ 'email_verified_at' => 'datetime', ]; + + + public function receipts() + { + return $this->hasMany('App\Models\Receipt'); + } }