2025-10-22 17:09:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2025-12-31 11:21:20 +01:00
|
|
|
use App\Enums\IspconfigType;
|
2025-10-22 17:09:48 +02:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
2025-10-26 00:16:25 +02:00
|
|
|
use Illuminate\Notifications\Notifiable;
|
2025-10-22 17:09:48 +02:00
|
|
|
|
2025-10-24 14:09:54 +02:00
|
|
|
/**
|
|
|
|
|
* @property int $id
|
|
|
|
|
* @property int|null $user_id
|
2025-11-15 17:09:56 +01:00
|
|
|
* @property string|null $dolibarr_id
|
2025-10-24 14:09:54 +02:00
|
|
|
* @property string|null $keycloak_id
|
|
|
|
|
* @property string $status
|
|
|
|
|
* @property string $nature
|
2025-11-15 17:09:56 +01:00
|
|
|
* @property int|null $type_id
|
2025-10-24 14:09:54 +02:00
|
|
|
* @property int|null $group_id
|
|
|
|
|
* @property string|null $lastname
|
|
|
|
|
* @property string|null $firstname
|
|
|
|
|
* @property string $email
|
2025-11-15 17:09:56 +01:00
|
|
|
* @property string|null $retzien_email
|
2025-10-24 14:09:54 +02:00
|
|
|
* @property string|null $company
|
|
|
|
|
* @property string|null $date_of_birth
|
|
|
|
|
* @property string|null $address
|
|
|
|
|
* @property string|null $zipcode
|
|
|
|
|
* @property string|null $city
|
|
|
|
|
* @property string|null $country
|
|
|
|
|
* @property string|null $phone1
|
|
|
|
|
* @property string|null $phone2
|
|
|
|
|
* @property int $public_membership
|
2025-11-15 17:09:56 +01:00
|
|
|
* @property string|null $website_url
|
2025-10-24 14:09:54 +02:00
|
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
|
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
|
|
|
* @property string|null $deleted_at
|
|
|
|
|
* @property-read string $full_name
|
|
|
|
|
* @property-read \App\Models\MemberGroup|null $group
|
|
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Membership> $memberships
|
|
|
|
|
* @property-read int|null $memberships_count
|
2025-11-15 17:09:56 +01:00
|
|
|
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
|
|
|
|
|
* @property-read int|null $notifications_count
|
2025-10-24 14:09:54 +02:00
|
|
|
* @property-read \App\Models\User|null $user
|
|
|
|
|
* @method static \Database\Factories\MemberFactory factory($count = null, $state = [])
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member newModelQuery()
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member newQuery()
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member query()
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereAddress($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereCity($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereCompany($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereCountry($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereCreatedAt($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereDateOfBirth($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereDeletedAt($value)
|
2025-11-15 17:09:56 +01:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereDolibarrId($value)
|
2025-10-24 14:09:54 +02:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereEmail($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereFirstname($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereGroupId($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereId($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereKeycloakId($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereLastname($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereNature($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member wherePhone1($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member wherePhone2($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member wherePublicMembership($value)
|
2025-11-15 17:09:56 +01:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereRetzienEmail($value)
|
2025-10-24 14:09:54 +02:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereStatus($value)
|
2025-11-15 17:09:56 +01:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereTypeId($value)
|
2025-10-24 14:09:54 +02:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereUpdatedAt($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereUserId($value)
|
2025-11-15 17:09:56 +01:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereWebsiteUrl($value)
|
2025-10-24 14:09:54 +02:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Member whereZipcode($value)
|
|
|
|
|
* @mixin \Eloquent
|
|
|
|
|
*/
|
2025-10-22 17:09:48 +02:00
|
|
|
class Member extends Model
|
|
|
|
|
{
|
2025-10-26 00:16:25 +02:00
|
|
|
use HasFactory, Notifiable;
|
2025-10-22 17:09:48 +02:00
|
|
|
protected $fillable = [
|
|
|
|
|
'user_id',
|
2025-11-15 17:09:56 +01:00
|
|
|
'dolibarr_id',
|
2025-10-22 17:09:48 +02:00
|
|
|
'keycloak_id',
|
|
|
|
|
'status',
|
|
|
|
|
'nature',
|
2025-11-15 17:09:56 +01:00
|
|
|
'type_id',
|
2025-10-22 17:09:48 +02:00
|
|
|
'group_id',
|
|
|
|
|
'lastname',
|
|
|
|
|
'firstname',
|
|
|
|
|
'email',
|
|
|
|
|
'company',
|
|
|
|
|
'date_of_birth',
|
|
|
|
|
'address',
|
|
|
|
|
'zipcode',
|
|
|
|
|
'city',
|
|
|
|
|
'country',
|
|
|
|
|
'phone1',
|
|
|
|
|
'phone2',
|
2025-10-24 14:09:54 +02:00
|
|
|
'public_membership',
|
2025-11-15 17:09:56 +01:00
|
|
|
'website_url'
|
2025-10-22 17:09:48 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public static function getAttributeLabel(string $attribute): string
|
|
|
|
|
{
|
|
|
|
|
return __("members.fields.$attribute");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getFullNameAttribute(): string
|
|
|
|
|
{
|
|
|
|
|
return "{$this->firstname} {$this->lastname}";
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-19 15:31:34 +01:00
|
|
|
public function getRetzienEmailAttribute(): string
|
|
|
|
|
{
|
|
|
|
|
$emails = explode(';', $this->email);
|
|
|
|
|
return collect($emails)->filter(fn($email) => str_contains($email, '@retzien.fr'))->first();
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-22 17:09:48 +02:00
|
|
|
public function user(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function group(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(MemberGroup::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function memberships(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Membership::class);
|
|
|
|
|
}
|
2025-12-31 11:21:20 +01:00
|
|
|
|
|
|
|
|
public function ispconfigs(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(IspconfigMember::class, 'member_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ispconfigMail(): ?IspconfigMember
|
|
|
|
|
{
|
|
|
|
|
return $this->ispconfigs()
|
|
|
|
|
->where('type', IspconfigType::MAIL)
|
|
|
|
|
->first();
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-18 14:35:41 +01:00
|
|
|
public function ispconfigsWeb(): ?IspconfigMember
|
2025-12-31 11:21:20 +01:00
|
|
|
{
|
|
|
|
|
return $this->ispconfigs()
|
|
|
|
|
->where('type', IspconfigType::WEB)
|
|
|
|
|
->first();
|
|
|
|
|
}
|
2026-01-19 15:31:34 +01:00
|
|
|
|
|
|
|
|
public function nextcloudAccounts(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(NextCloudMember::class, 'member_id');
|
|
|
|
|
}
|
2025-10-22 17:09:48 +02:00
|
|
|
}
|