Add Entities definitions

This commit is contained in:
Antoine Le Gonidec 2024-07-16 12:18:43 +02:00
parent 42da48ce2b
commit 1c456d4aca
Signed by: vv221
GPG key ID: 636B78F91CEB80D8
3 changed files with 61 additions and 0 deletions

18
Entities/Customer.php Normal file
View file

@ -0,0 +1,18 @@
<?php
/*
SPDX-License-Identifier: AGPL-3.0-only
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
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);
}
}

View file

@ -0,0 +1,25 @@
<?php
/*
SPDX-License-Identifier: AGPL-3.0-only
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
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);
}
}

18
Entities/Mailbox.php Normal file
View file

@ -0,0 +1,18 @@
<?php
/*
SPDX-License-Identifier: AGPL-3.0-only
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
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);
}
}