created admin panel with some of its content
This commit is contained in:
1 parent
2ee4b76599
commit
b16351c416
52 files changed
+5690
-203
No files matched your search
+143
-1
@@ -7,10 +7,11 @@ 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\SoftDeletes;
|
||||
|
||||
class Tenant extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -22,8 +23,25 @@ class Tenant extends Model
|
||||
'club_name',
|
||||
'slug',
|
||||
'logo',
|
||||
'slogan',
|
||||
'description',
|
||||
'enrollment_fee',
|
||||
'commercial_reg_number',
|
||||
'vat_reg_number',
|
||||
'vat_percentage',
|
||||
'email',
|
||||
'phone',
|
||||
'currency',
|
||||
'timezone',
|
||||
'country',
|
||||
'address',
|
||||
'favicon',
|
||||
'cover_image',
|
||||
'owner_name',
|
||||
'owner_email',
|
||||
'gps_lat',
|
||||
'gps_long',
|
||||
'settings',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -34,6 +52,10 @@ class Tenant extends Model
|
||||
protected $casts = [
|
||||
'gps_lat' => 'decimal:7',
|
||||
'gps_long' => 'decimal:7',
|
||||
'enrollment_fee' => 'decimal:2',
|
||||
'vat_percentage' => 'decimal:2',
|
||||
'phone' => 'array',
|
||||
'settings' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -61,4 +83,124 @@ class Tenant extends Model
|
||||
{
|
||||
return $this->hasMany(Invoice::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the facilities for the club.
|
||||
*/
|
||||
public function facilities(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClubFacility::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the instructors for the club.
|
||||
*/
|
||||
public function instructors(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClubInstructor::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the activities for the club.
|
||||
*/
|
||||
public function activities(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClubActivity::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the packages for the club.
|
||||
*/
|
||||
public function packages(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClubPackage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subscriptions for the club.
|
||||
*/
|
||||
public function subscriptions(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClubMemberSubscription::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transactions for the club.
|
||||
*/
|
||||
public function transactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClubTransaction::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the gallery images for the club.
|
||||
*/
|
||||
public function galleryImages(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClubGalleryImage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the social links for the club.
|
||||
*/
|
||||
public function socialLinks(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClubSocialLink::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bank accounts for the club.
|
||||
*/
|
||||
public function bankAccounts(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClubBankAccount::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the messages for the club.
|
||||
*/
|
||||
public function messages(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClubMessage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reviews for the club.
|
||||
*/
|
||||
public function reviews(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClubReview::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get approved reviews for the club.
|
||||
*/
|
||||
public function approvedReviews(): HasMany
|
||||
{
|
||||
return $this->hasMany(ClubReview::class)->where('is_approved', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the average rating for the club.
|
||||
*/
|
||||
public function getAverageRatingAttribute(): float
|
||||
{
|
||||
return $this->approvedReviews()->avg('rating') ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active members count.
|
||||
*/
|
||||
public function getActiveMembersCountAttribute(): int
|
||||
{
|
||||
return $this->subscriptions()->where('status', 'active')->distinct('user_id')->count('user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the club URL.
|
||||
*/
|
||||
public function getUrlAttribute(): string
|
||||
{
|
||||
return url("/club/{$this->slug}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user