using cloude sonet 3.5 i have used the prompt to create the migrations and their files and installed api package

This commit is contained in:
ghassan committed 2026-01-20 10:06:01 +03:00
1 parent f27b5abf02
commit 4a7353e3fc
23 files changed
+1871 -2

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Invoice extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'tenant_id',
'amount',
'status',
'due_date',
'student_user_id',
'payer_user_id',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'amount' => 'decimal:2',
'due_date' => 'date',
];
/**
* Get the tenant that owns the invoice.
*/
public function tenant(): BelongsTo
{
return $this->belongsTo(Tenant::class);
}
/**
* Get the student user that owns the invoice.
*/
public function student(): BelongsTo
{
return $this->belongsTo(User::class, 'student_user_id');
}
/**
* Get the payer user that owns the invoice.
*/
public function payer(): BelongsTo
{
return $this->belongsTo(User::class, 'payer_user_id');
}
}
+48
View File
@@ -0,0 +1,48 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Membership extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'tenant_id',
'user_id',
'status',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'status' => 'string',
];
/**
* Get the tenant that owns the membership.
*/
public function tenant(): BelongsTo
{
return $this->belongsTo(Tenant::class);
}
/**
* Get the user that owns the membership.
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}
+64
View File
@@ -0,0 +1,64 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Tenant extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'owner_user_id',
'club_name',
'slug',
'logo',
'gps_lat',
'gps_long',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'gps_lat' => 'decimal:7',
'gps_long' => 'decimal:7',
];
/**
* Get the owner user that owns the tenant.
*/
public function owner(): BelongsTo
{
return $this->belongsTo(User::class, 'owner_user_id');
}
/**
* Get the members for the tenant.
*/
public function members(): BelongsToMany
{
return $this->belongsToMany(User::class, 'memberships')
->withPivot('status')
->withTimestamps();
}
/**
* Get the invoices for the tenant.
*/
public function invoices(): HasMany
{
return $this->hasMany(Invoice::class);
}
}
+153 -1
View File
@@ -6,6 +6,10 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Carbon\Carbon;
class User extends Authenticatable
{
@@ -18,9 +22,17 @@ class User extends Authenticatable
* @var list<string>
*/
protected $fillable = [
'name',
'full_name',
'email',
'mobile',
'password',
'gender',
'birthdate',
'blood_type',
'nationality',
'addresses',
'social_links',
'media_gallery',
];
/**
@@ -43,6 +55,146 @@ class User extends Authenticatable
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'birthdate' => 'date',
'addresses' => 'array',
'social_links' => 'array',
'media_gallery' => 'array',
];
}
/**
* Get the user's age based on birthdate.
*/
protected function age(): Attribute
{
return Attribute::make(
get: function () {
if (!$this->birthdate) {
return null;
}
return Carbon::parse($this->birthdate)->age;
}
);
}
/**
* Get the user's horoscope based on birthdate.
*/
protected function horoscope(): Attribute
{
return Attribute::make(
get: function () {
if (!$this->birthdate) {
return null;
}
$month = $this->birthdate->month;
$day = $this->birthdate->day;
if (($month == 3 && $day >= 21) || ($month == 4 && $day <= 19)) {
return 'Aries';
} elseif (($month == 4 && $day >= 20) || ($month == 5 && $day <= 20)) {
return 'Taurus';
} elseif (($month == 5 && $day >= 21) || ($month == 6 && $day <= 20)) {
return 'Gemini';
} elseif (($month == 6 && $day >= 21) || ($month == 7 && $day <= 22)) {
return 'Cancer';
} elseif (($month == 7 && $day >= 23) || ($month == 8 && $day <= 22)) {
return 'Leo';
} elseif (($month == 8 && $day >= 23) || ($month == 9 && $day <= 22)) {
return 'Virgo';
} elseif (($month == 9 && $day >= 23) || ($month == 10 && $day <= 22)) {
return 'Libra';
} elseif (($month == 10 && $day >= 23) || ($month == 11 && $day <= 21)) {
return 'Scorpio';
} elseif (($month == 11 && $day >= 22) || ($month == 12 && $day <= 21)) {
return 'Sagittarius';
} elseif (($month == 12 && $day >= 22) || ($month == 1 && $day <= 19)) {
return 'Capricorn';
} elseif (($month == 1 && $day >= 20) || ($month == 2 && $day <= 18)) {
return 'Aquarius';
} else {
return 'Pisces';
}
}
);
}
/**
* Get the user's life stage based on age.
*/
protected function lifeStage(): Attribute
{
return Attribute::make(
get: function () {
if (!$this->birthdate) {
return null;
}
$age = Carbon::parse($this->birthdate)->age;
if ($age >= 0 && $age <= 3) {
return 'Toddler';
} elseif ($age >= 4 && $age <= 12) {
return 'Child';
} elseif ($age >= 13 && $age <= 19) {
return 'Teenager';
} elseif ($age >= 20 && $age <= 59) {
return 'Adult';
} else {
return 'Senior';
}
}
);
}
/**
* Get the dependents for the user.
*/
public function dependents(): HasMany
{
return $this->hasMany(UserRelationship::class, 'guardian_user_id');
}
/**
* Get the guardians for the user.
*/
public function guardians(): HasMany
{
return $this->hasMany(UserRelationship::class, 'dependent_user_id');
}
/**
* Get the clubs owned by the user.
*/
public function ownedClubs(): HasMany
{
return $this->hasMany(Tenant::class, 'owner_user_id');
}
/**
* Get the clubs the user is a member of.
*/
public function memberClubs(): BelongsToMany
{
return $this->belongsToMany(Tenant::class, 'memberships')
->withPivot('status')
->withTimestamps();
}
/**
* Get the invoices where the user is the student.
*/
public function studentInvoices(): HasMany
{
return $this->hasMany(Invoice::class, 'student_user_id');
}
/**
* Get the invoices where the user is the payer.
*/
public function payerInvoices(): HasMany
{
return $this->hasMany(Invoice::class, 'payer_user_id');
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class UserRelationship extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'guardian_user_id',
'dependent_user_id',
'relationship_type',
'is_billing_contact',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'is_billing_contact' => 'boolean',
];
/**
* Get the guardian user that owns the relationship.
*/
public function guardian(): BelongsTo
{
return $this->belongsTo(User::class, 'guardian_user_id');
}
/**
* Get the dependent user that belongs to the relationship.
*/
public function dependent(): BelongsTo
{
return $this->belongsTo(User::class, 'dependent_user_id');
}
}