2024-07-16 10:18:43 +00:00
|
|
|
<?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 {
|
2024-07-17 12:45:39 +00:00
|
|
|
public $timestamps = false;
|
|
|
|
|
2024-07-16 10:18:43 +00:00
|
|
|
/**
|
|
|
|
* 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() {
|
2024-07-17 12:45:39 +00:00
|
|
|
return $this->belongsToMany(Customer::class, 'customers_group_customers');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the list of Emails that are included in this group.
|
|
|
|
*/
|
|
|
|
public function emails() {
|
|
|
|
$customers = $this->customers;
|
|
|
|
// Get a list of Emails from the list of Customers.
|
|
|
|
$emails = $customers
|
|
|
|
->pluck('emails')
|
|
|
|
->flatten();
|
|
|
|
return $emails;
|
2024-07-16 10:18:43 +00:00
|
|
|
}
|
|
|
|
}
|