added affiliation tab card with its information

This commit is contained in:
ghassan committed 2026-01-24 14:52:55 +03:00
1 parent 352d54a788
commit c1fc28087e
14 files changed
+1493 -47

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class AffiliationMedia extends Model
{
protected $fillable = [
'club_affiliation_id',
'media_type',
'media_url',
'title',
'description',
];
/**
* Get the club affiliation that owns the media.
*/
public function clubAffiliation(): BelongsTo
{
return $this->belongsTo(ClubAffiliation::class);
}
/**
* Get the full URL for the media.
*/
public function getFullUrlAttribute(): string
{
if (filter_var($this->media_url, FILTER_VALIDATE_URL)) {
return $this->media_url;
}
return asset('storage/' . $this->media_url);
}
/**
* Get icon class for media type.
*/
public function getIconClassAttribute(): string
{
return match($this->media_type) {
'certificate' => 'bi-file-earmark-text',
'photo' => 'bi-image',
'video' => 'bi-play-circle',
'document' => 'bi-file-text',
default => 'bi-file',
};
}
}
+93
View File
@@ -0,0 +1,93 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class ClubAffiliation extends Model
{
protected $fillable = [
'member_id',
'club_name',
'logo',
'start_date',
'end_date',
'location',
'coaches',
'description',
];
protected $casts = [
'start_date' => 'date',
'end_date' => 'date',
'coaches' => 'array',
];
/**
* Get the member that owns the affiliation.
*/
public function member(): BelongsTo
{
return $this->belongsTo(User::class, 'member_id');
}
/**
* Get the skills acquired during this affiliation.
*/
public function skillAcquisitions(): HasMany
{
return $this->hasMany(SkillAcquisition::class);
}
/**
* Get the media associated with this affiliation.
*/
public function affiliationMedia(): HasMany
{
return $this->hasMany(AffiliationMedia::class);
}
/**
* Get the duration of the affiliation in months.
*/
public function getDurationInMonthsAttribute(): int
{
$endDate = $this->end_date ?? now();
return $this->start_date->diffInMonths($endDate);
}
/**
* Get formatted date range.
*/
public function getDateRangeAttribute(): string
{
$start = $this->start_date->format('M Y');
$end = $this->end_date ? $this->end_date->format('M Y') : 'Present';
return $start . ' – ' . $end;
}
/**
* Get detailed formatted duration (years, months, days).
*/
public function getFormattedDurationAttribute(): string
{
$endDate = $this->end_date ?? now();
$diff = $this->start_date->diff($endDate);
$parts = [];
if ($diff->y > 0) {
$parts[] = $diff->y . ' year' . ($diff->y > 1 ? 's' : '');
}
if ($diff->m > 0) {
$parts[] = $diff->m . ' month' . ($diff->m > 1 ? 's' : '');
}
if ($diff->d > 0) {
$parts[] = $diff->d . ' day' . ($diff->d > 1 ? 's' : '');
}
return implode(' ', $parts) ?: 'Same day';
}
}
+64
View File
@@ -0,0 +1,64 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class SkillAcquisition extends Model
{
protected $fillable = [
'club_affiliation_id',
'skill_name',
'icon',
'duration_months',
'proficiency_level',
];
protected $casts = [
'duration_months' => 'integer',
];
/**
* Get the club affiliation that owns the skill acquisition.
*/
public function clubAffiliation(): BelongsTo
{
return $this->belongsTo(ClubAffiliation::class);
}
/**
* Get formatted duration.
*/
public function getFormattedDurationAttribute(): string
{
$months = $this->duration_months;
if ($months < 12) {
return $months . ' month' . ($months > 1 ? 's' : '');
}
$years = floor($months / 12);
$remainingMonths = $months % 12;
$result = $years . ' year' . ($years > 1 ? 's' : '');
if ($remainingMonths > 0) {
$result .= ' ' . $remainingMonths . ' month' . ($remainingMonths > 1 ? 's' : '');
}
return $result;
}
/**
* Get proficiency level color for UI.
*/
public function getProficiencyColorAttribute(): string
{
return match($this->proficiency_level) {
'beginner' => 'text-blue-500',
'intermediate' => 'text-yellow-500',
'advanced' => 'text-orange-500',
'expert' => 'text-red-500',
default => 'text-gray-500',
};
}
}
+6
View File
@@ -10,6 +10,7 @@ class TournamentEvent extends Model
{
protected $fillable = [
'user_id',
'club_affiliation_id',
'title',
'type',
'sport',
@@ -29,6 +30,11 @@ class TournamentEvent extends Model
return $this->belongsTo(User::class);
}
public function clubAffiliation(): BelongsTo
{
return $this->belongsTo(ClubAffiliation::class);
}
public function performanceResults(): HasMany
{
return $this->hasMany(PerformanceResult::class);
+8
View File
@@ -250,6 +250,14 @@ class User extends Authenticatable
return $this->hasMany(Attendance::class, 'member_id');
}
/**
* Get the club affiliations for the user.
*/
public function clubAffiliations(): HasMany
{
return $this->hasMany(ClubAffiliation::class, 'member_id');
}
/**
* Send the email verification notification.
* Override to prevent sending the default Laravel notification.