From 1c456d4aca6f6ae82a91274a96698bc49f36e9d2 Mon Sep 17 00:00:00 2001 From: Antoine Le Gonidec Date: Tue, 16 Jul 2024 12:18:43 +0200 Subject: [PATCH] Add Entities definitions --- Entities/Customer.php | 18 ++++++++++++++++++ Entities/CustomersGroup.php | 25 +++++++++++++++++++++++++ Entities/Mailbox.php | 18 ++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 Entities/Customer.php create mode 100644 Entities/CustomersGroup.php create mode 100644 Entities/Mailbox.php diff --git a/Entities/Customer.php b/Entities/Customer.php new file mode 100644 index 0000000..1a16936 --- /dev/null +++ b/Entities/Customer.php @@ -0,0 +1,18 @@ + + */ + +namespace Modules\MMFCustomersGroups\Entities; + +use App\Customer as BaseCustomer; + +class Customer extends BaseCustomer { + /** + * Get the groups this Customer belongs to. + */ + public function groups() { + return $this->belongsToMany(CustomersGroup::class); + } +} diff --git a/Entities/CustomersGroup.php b/Entities/CustomersGroup.php new file mode 100644 index 0000000..75b70f4 --- /dev/null +++ b/Entities/CustomersGroup.php @@ -0,0 +1,25 @@ + + */ + +namespace Modules\MMFCustomersGroups\Entities; + +use Illuminate\Database\Eloquent\Model; + +class CustomersGroup extends Model { + /** + * Get the Mailbox this group is linked to. + */ + public function mailbox() { + return $this->belongsTo(Mailbox::class); + } + + /** + * Get the Customers that are included in this group. + */ + public function customers() { + return $this->belongsToMany(Customer::class); + } +} diff --git a/Entities/Mailbox.php b/Entities/Mailbox.php new file mode 100644 index 0000000..72a13e9 --- /dev/null +++ b/Entities/Mailbox.php @@ -0,0 +1,18 @@ + + */ + +namespace Modules\MMFCustomersGroups\Entities; + +use App\Mailbox as BaseMailbox; + +class Mailbox extends BaseMailbox { + /** + * Get the customers groups linked to this Mailbox. + */ + public function groups() { + return $this->hasMany(CustomersGroup::class); + } +}