From 1ddeb1cac64c0beb7bc7ca83f28201e4684b49f5 Mon Sep 17 00:00:00 2001 From: weichien00 Date: Sat, 26 Jun 2021 00:43:21 +0800 Subject: [PATCH] new: Add models currency, passwordReset, segmentCompany, segmentConstant. #1 --- app/Models/Currency.php | 44 +++++++++++++++++++++++++++++++ app/Models/PasswordReset.php | 25 ++++++++++++++++++ app/Models/SegmentCompany.php | 8 ++++++ app/Models/SegmentConstant.php | 47 ++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 app/Models/Currency.php create mode 100644 app/Models/PasswordReset.php create mode 100644 app/Models/SegmentCompany.php create mode 100644 app/Models/SegmentConstant.php diff --git a/app/Models/Currency.php b/app/Models/Currency.php new file mode 100644 index 00000000..cf3b4a6f --- /dev/null +++ b/app/Models/Currency.php @@ -0,0 +1,44 @@ +BelongsTo(Country::class, 'country_id', 'id'); + } + + /** + * @return hasMany + */ + public function rates(): hasMany + { + return $this->hasMany(CurrencyRate::class, 'currency_id'); + } +} diff --git a/app/Models/PasswordReset.php b/app/Models/PasswordReset.php new file mode 100644 index 00000000..6ab27179 --- /dev/null +++ b/app/Models/PasswordReset.php @@ -0,0 +1,25 @@ +where('is_expired', false)->where('is_complete', false); + } + + /** + * @return BelongsTo + */ + public function user(): BelongsTo { + return $this->belongsTo(User::class, 'user_id', 'id'); + } +} diff --git a/app/Models/SegmentCompany.php b/app/Models/SegmentCompany.php new file mode 100644 index 00000000..660057fc --- /dev/null +++ b/app/Models/SegmentCompany.php @@ -0,0 +1,8 @@ +BelongsTo(Segment::class, 'segment_id', 'id'); + } + + /** + * @return mixed + */ + public function service(){ + return $this->hasOne(ServiceType::class, 'id', 'detail->id') + ->whereIn('reference', [SegmentConstants::SERVICE_TYPE, SegmentConstants::CUSTOM_SERVICE_TYPE]); + } + + + +}