use Cubedesigners\UserDatabase\Permissions;
use Cubedesigners\UserDatabase\SubForms\Address;
use Cubedesigners\UserDatabase\SubForms\AddressAndCompanyName;
+use Cubedesigners\UserDatabase\Traits\OtherEmails;
use Cubist\Backpack\Magic\Fields\Checkbox;
use Cubist\Backpack\Magic\Fields\Date;
use Cubist\Backpack\Magic\Fields\Hidden;
class Company extends CubistMagicAbstractModel
{
+ use OtherEmails;
+
protected $connection = 'extranet_users';
protected $table = 'company';
protected $_options = ['name' => 'company',
'form' => 'update',
]);
+ $this->addOtherEmailsField(__('Contacts'));
+
$this->addField(['name' => 'website',
'type' => 'URL',
'label' => __('Site web'),
use Cubedesigners\UserDatabase\Operations\LoginasOperation;
use Cubedesigners\UserDatabase\Permissions;
use Cubedesigners\UserDatabase\SubForms\Address;
+use Cubedesigners\UserDatabase\Traits\OtherEmails;
use Cubist\Backpack\Magic\Fields\Checkbox;
use Cubist\Backpack\Magic\Fields\Color;
use Cubist\Backpack\Magic\Fields\Hidden;
class User extends CubistMagicAuthenticatable implements HasLocalePreference
{
+ use OtherEmails;
+
protected $connection = 'extranet_users';
protected $table = 'user';
protected $_options = ['name' => 'users',
'type' => 'Phone',
'tab' => __('Contact')]);
+ $this->addOtherEmailsField(__('Contact'));
+
$this->addField(['name' => 'marketing',
'label' => __('Reçoit les communications marketing'),
'type' => Checkbox::class,
$p = $this->getField('rolesandperms');
$p->setAttribute('tab', __('Equipe Cubedesigners'));
-
-
}
public function getNameAttribute()
return $this->_managedUsers;
}
+
public function getManagedCompanies()
{
if (null === $this->_managedCompanies) {
--- /dev/null
+<?php
+
+namespace Cubedesigners\UserDatabase\Traits;
+
+use Cubist\Backpack\Magic\Fields\Textarea;
+
+trait OtherEmails
+{
+ public function getEmails()
+ {
+ $res = [];
+ if (property_exists($this, 'email')) {
+ $res[] = trim(mb_strtolower($this->email));
+ }
+ if (!$this->emails_other) {
+ return $res;
+ }
+
+ foreach (\Cubist\Util\Text::explodeNewLines($this->emails_other) as $e) {
+ $e = trim(mb_strtolower($e));
+ if (\Cubist\Util\Text::isEmail($e)) {
+ $res[] = $e;
+ }
+
+ }
+ return $res;
+ }
+
+ public function addOtherEmailsField($tab)
+ {
+ $this->addField('emails_other', Textarea::class, __('Autres emails'),
+ ['hint' => __('Ces emails sont ajoutés à la liste blanche des SPAM. Une adresse par ligne.'), 'tab' => $tab]);
+ }
+}