2025-10-22 17:09:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
|
|
|
|
2025-10-24 14:09:54 +02:00
|
|
|
/**
|
|
|
|
|
* @property int $id
|
|
|
|
|
* @property int $member_id
|
|
|
|
|
* @property int|null $admin_id
|
|
|
|
|
* @property int $package_id
|
2025-11-15 17:09:56 +01:00
|
|
|
* @property string|null $start_date
|
2025-10-24 14:09:54 +02:00
|
|
|
* @property string|null $end_date
|
|
|
|
|
* @property string $status
|
2025-11-15 17:09:56 +01:00
|
|
|
* @property string|null $validation_date
|
|
|
|
|
* @property string|null $payment_method
|
2025-10-24 14:09:54 +02:00
|
|
|
* @property string $amount
|
|
|
|
|
* @property string $payment_status
|
2025-11-15 17:09:56 +01:00
|
|
|
* @property string|null $note_public
|
|
|
|
|
* @property string|null $note_private
|
|
|
|
|
* @property string|null $dolibarr_id
|
|
|
|
|
* @property string|null $dolibarr_user_id
|
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 \App\Models\User|null $author
|
|
|
|
|
* @property-read \App\Models\Member $member
|
|
|
|
|
* @property-read \App\Models\Package $package
|
|
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Service> $services
|
|
|
|
|
* @property-read int|null $services_count
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership newModelQuery()
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership newQuery()
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership query()
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereAdminId($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereAmount($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereCreatedAt($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereDeletedAt($value)
|
2025-11-15 17:09:56 +01:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereDolibarrId($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereDolibarrUserId($value)
|
2025-10-24 14:09:54 +02:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereEndDate($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereId($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereMemberId($value)
|
2025-11-15 17:09:56 +01:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereNotePrivate($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereNotePublic($value)
|
2025-10-24 14:09:54 +02:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership wherePackageId($value)
|
2025-11-15 17:09:56 +01:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership wherePaymentMethod($value)
|
2025-10-24 14:09:54 +02:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership wherePaymentStatus($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereStartDate($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereStatus($value)
|
|
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereUpdatedAt($value)
|
2025-11-15 17:09:56 +01:00
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Membership whereValidationDate($value)
|
2025-10-24 14:09:54 +02:00
|
|
|
* @mixin \Eloquent
|
|
|
|
|
*/
|
2025-10-22 17:09:48 +02:00
|
|
|
class Membership extends Model
|
|
|
|
|
{
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'member_id',
|
|
|
|
|
'admin_id',
|
|
|
|
|
'package_id',
|
|
|
|
|
'start_date',
|
|
|
|
|
'end_date',
|
|
|
|
|
'status',
|
2025-11-15 17:09:56 +01:00
|
|
|
'validation_date',
|
|
|
|
|
'payment_method',
|
2025-10-22 17:09:48 +02:00
|
|
|
'amount',
|
|
|
|
|
'payment_status',
|
2025-11-15 17:09:56 +01:00
|
|
|
'note_public',
|
|
|
|
|
'note_private',
|
|
|
|
|
'dolibarr_id',
|
|
|
|
|
'dolibarr_user_id'
|
2025-10-22 17:09:48 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function getAttributeLabel(string $attribute): string
|
|
|
|
|
{
|
2025-10-26 00:16:25 +02:00
|
|
|
return __("memberships.fields.$attribute");
|
2025-10-22 17:09:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function member(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(Member::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function author(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class, 'admin_id');
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-23 16:12:40 +02:00
|
|
|
public function package(): BelongsTo
|
2025-10-22 17:09:48 +02:00
|
|
|
{
|
2025-10-23 16:12:40 +02:00
|
|
|
return $this->belongsTo(Package::class);
|
2025-10-22 17:09:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function services(): BelongsToMany
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsToMany(Service::class, 'services_memberships', 'membership_id', 'service_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|