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 Yusuf 2026-01-20 10:06:01 +03:00
parent f27b5abf02
commit 4a7353e3fc
23 changed files with 1871 additions and 2 deletions

View File

@ -0,0 +1,168 @@
<?php
namespace App\Http\Controllers;
use App\Models\User;
use App\Models\UserRelationship;
use App\Services\FamilyService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class FamilyController extends Controller
{
protected $familyService;
public function __construct(FamilyService $familyService)
{
$this->familyService = $familyService;
}
/**
* Display the family dashboard.
*
* @return \Illuminate\View\View
*/
public function dashboard()
{
$user = Auth::user();
$dependents = UserRelationship::where('guardian_user_id', $user->id)
->with('dependent')
->get();
$familyInvoices = $this->familyService->getFamilyInvoices($user->id);
return view('family.dashboard', compact('user', 'dependents', 'familyInvoices'));
}
/**
* Show the form for creating a new family member.
*
* @return \Illuminate\View\View
*/
public function create()
{
return view('family.create');
}
/**
* Store a newly created family member in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(Request $request)
{
$validated = $request->validate([
'full_name' => 'required|string|max:255',
'email' => 'nullable|email|max:255',
'gender' => 'required|in:male,female',
'birthdate' => 'required|date',
'blood_type' => 'nullable|string|max:10',
'nationality' => 'required|string|max:100',
'relationship_type' => 'required|string|max:50',
'is_billing_contact' => 'boolean',
]);
$guardian = Auth::user();
$dependent = $this->familyService->createDependent($guardian, $validated);
return redirect()->route('family.dashboard')
->with('success', 'Family member added successfully.');
}
/**
* Display the specified family member.
*
* @param int $id
* @return \Illuminate\View\View
*/
public function show($id)
{
$user = Auth::user();
$relationship = UserRelationship::where('guardian_user_id', $user->id)
->where('dependent_user_id', $id)
->with('dependent')
->firstOrFail();
return view('family.show', compact('relationship'));
}
/**
* Show the form for editing the specified family member.
*
* @param int $id
* @return \Illuminate\View\View
*/
public function edit($id)
{
$user = Auth::user();
$relationship = UserRelationship::where('guardian_user_id', $user->id)
->where('dependent_user_id', $id)
->with('dependent')
->firstOrFail();
return view('family.edit', compact('relationship'));
}
/**
* Update the specified family member in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\RedirectResponse
*/
public function update(Request $request, $id)
{
$validated = $request->validate([
'full_name' => 'required|string|max:255',
'email' => 'nullable|email|max:255',
'gender' => 'required|in:male,female',
'birthdate' => 'required|date',
'blood_type' => 'nullable|string|max:10',
'nationality' => 'required|string|max:100',
'relationship_type' => 'required|string|max:50',
'is_billing_contact' => 'boolean',
]);
$user = Auth::user();
$relationship = UserRelationship::where('guardian_user_id', $user->id)
->where('dependent_user_id', $id)
->firstOrFail();
$dependent = User::findOrFail($id);
$dependent->update([
'full_name' => $validated['full_name'],
'email' => $validated['email'],
'gender' => $validated['gender'],
'birthdate' => $validated['birthdate'],
'blood_type' => $validated['blood_type'],
'nationality' => $validated['nationality'],
]);
$relationship->update([
'relationship_type' => $validated['relationship_type'],
'is_billing_contact' => $validated['is_billing_contact'] ?? false,
]);
return redirect()->route('family.dashboard')
->with('success', 'Family member updated successfully.');
}
/**
* Remove the specified family member from storage.
*
* @param int $id
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy($id)
{
$user = Auth::user();
$relationship = UserRelationship::where('guardian_user_id', $user->id)
->where('dependent_user_id', $id)
->firstOrFail();
$relationship->delete();
return redirect()->route('family.dashboard')
->with('success', 'Family member removed successfully.');
}
}

View File

@ -0,0 +1,92 @@
<?php
namespace App\Http\Controllers;
use App\Models\Invoice;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class InvoiceController extends Controller
{
public function __construct()
{
// Auth middleware will be applied in routes
}
/**
* Display a listing of the invoices.
*
* @return \Illuminate\View\View
*/
public function index()
{
$user = Auth::user();
$invoices = Invoice::where('payer_user_id', $user->id)
->with(['student', 'tenant'])
->get();
return view('invoices.index', compact('invoices'));
}
/**
* Display the specified invoice.
*
* @param int $id
* @return \Illuminate\View\View
*/
public function show($id)
{
$user = Auth::user();
$invoice = Invoice::where('id', $id)
->where('payer_user_id', $user->id)
->with(['student', 'tenant'])
->firstOrFail();
return view('invoices.show', compact('invoice'));
}
/**
* Process payment for the specified invoice.
*
* @param int $id
* @return \Illuminate\Http\RedirectResponse
*/
public function pay($id)
{
$user = Auth::user();
$invoice = Invoice::where('id', $id)
->where('payer_user_id', $user->id)
->firstOrFail();
// In a real application, this would integrate with a payment gateway
$invoice->update([
'status' => 'paid'
]);
return redirect()->route('invoices.show', $invoice->id)
->with('success', 'Payment processed successfully.');
}
/**
* Process payment for all unpaid invoices.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function payAll()
{
$user = Auth::user();
$invoices = Invoice::where('payer_user_id', $user->id)
->where('status', '!=', 'paid')
->get();
// In a real application, this would integrate with a payment gateway
foreach ($invoices as $invoice) {
$invoice->update([
'status' => 'paid'
]);
}
return redirect()->route('invoices.index')
->with('success', 'All payments processed successfully.');
}
}

60
app/Models/Invoice.php Normal file
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
app/Models/Membership.php Normal file
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
app/Models/Tenant.php Normal file
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);
}
}

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');
}
}

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');
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace App\Services;
use App\Models\User;
use App\Models\UserRelationship;
use App\Models\Invoice;
class FamilyService
{
/**
* Create a new dependent user and link it to the guardian.
*
* @param User $guardian The guardian user
* @param array $data The dependent user data
* @return User The newly created dependent user
*/
public function createDependent(User $guardian, array $data): User
{
// Create the dependent user
$dependent = User::create([
'full_name' => $data['full_name'],
'email' => $data['email'] ?? null,
'password' => $data['password'] ?? null,
'mobile' => $data['mobile'] ?? null,
'gender' => $data['gender'],
'birthdate' => $data['birthdate'],
'blood_type' => $data['blood_type'] ?? null,
'nationality' => $data['nationality'],
'addresses' => $data['addresses'] ?? [],
'social_links' => $data['social_links'] ?? [],
'media_gallery' => $data['media_gallery'] ?? [],
]);
// Create the relationship between guardian and dependent
UserRelationship::create([
'guardian_user_id' => $guardian->id,
'dependent_user_id' => $dependent->id,
'relationship_type' => $data['relationship_type'],
'is_billing_contact' => $data['is_billing_contact'] ?? false,
]);
return $dependent;
}
/**
* Get all invoices where the guardian is the payer.
*
* @param int $guardianId The guardian user ID
* @return \Illuminate\Database\Eloquent\Collection The invoices
*/
public function getFamilyInvoices(int $guardianId)
{
return Invoice::where('payer_user_id', $guardianId)
->with('student')
->get();
}
}

View File

@ -7,6 +7,7 @@ use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)

View File

@ -8,6 +8,7 @@
"require": {
"php": "^8.2",
"laravel/framework": "^12.0",
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.10.1"
},
"require-dev": {

65
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c514d8f7b9fc5970bdd94287905ef584",
"content-hash": "d3c16cb86c42230c6c023d9a5d9bcf42",
"packages": [
{
"name": "brick/math",
@ -1333,6 +1333,69 @@
},
"time": "2026-01-13T20:29:29+00:00"
},
{
"name": "laravel/sanctum",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/laravel/sanctum.git",
"reference": "47d26f1d310879ff757b971f5a6fc631d18663fd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/sanctum/zipball/47d26f1d310879ff757b971f5a6fc631d18663fd",
"reference": "47d26f1d310879ff757b971f5a6fc631d18663fd",
"shasum": ""
},
"require": {
"ext-json": "*",
"illuminate/console": "^11.0|^12.0",
"illuminate/contracts": "^11.0|^12.0",
"illuminate/database": "^11.0|^12.0",
"illuminate/support": "^11.0|^12.0",
"php": "^8.2",
"symfony/console": "^7.0"
},
"require-dev": {
"mockery/mockery": "^1.6",
"orchestra/testbench": "^9.15|^10.8",
"phpstan/phpstan": "^1.10"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Laravel\\Sanctum\\SanctumServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Laravel\\Sanctum\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.",
"keywords": [
"auth",
"laravel",
"sanctum"
],
"support": {
"issues": "https://github.com/laravel/sanctum/issues",
"source": "https://github.com/laravel/sanctum"
},
"time": "2026-01-11T18:20:25+00:00"
},
{
"name": "laravel/serializable-closure",
"version": "v2.0.8",

84
config/sanctum.php Normal file
View File

@ -0,0 +1,84 @@
<?php
use Laravel\Sanctum\Sanctum;
return [
/*
|--------------------------------------------------------------------------
| Stateful Domains
|--------------------------------------------------------------------------
|
| Requests from the following domains / hosts will receive stateful API
| authentication cookies. Typically, these should include your local
| and production domains which access your API via a frontend SPA.
|
*/
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
Sanctum::currentApplicationUrlWithPort(),
// Sanctum::currentRequestHost(),
))),
/*
|--------------------------------------------------------------------------
| Sanctum Guards
|--------------------------------------------------------------------------
|
| This array contains the authentication guards that will be checked when
| Sanctum is trying to authenticate a request. If none of these guards
| are able to authenticate the request, Sanctum will use the bearer
| token that's present on an incoming request for authentication.
|
*/
'guard' => ['web'],
/*
|--------------------------------------------------------------------------
| Expiration Minutes
|--------------------------------------------------------------------------
|
| This value controls the number of minutes until an issued token will be
| considered expired. This will override any values set in the token's
| "expires_at" attribute, but first-party sessions are not affected.
|
*/
'expiration' => null,
/*
|--------------------------------------------------------------------------
| Token Prefix
|--------------------------------------------------------------------------
|
| Sanctum can prefix new tokens in order to take advantage of numerous
| security scanning initiatives maintained by open source platforms
| that notify developers if they commit tokens into repositories.
|
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
*/
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
/*
|--------------------------------------------------------------------------
| Sanctum Middleware
|--------------------------------------------------------------------------
|
| When authenticating your first-party SPA with Sanctum you may need to
| customize some of the middleware Sanctum uses while processing the
| request. You may change the middleware listed below as required.
|
*/
'middleware' => [
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
],
];

View File

@ -0,0 +1,103 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// 1. Drop the existing users table
Schema::dropIfExists('users');
// 2. Create a new users table with all required columns
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('full_name');
$table->string('email')->nullable()->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('mobile')->nullable();
$table->string('password')->nullable();
$table->rememberToken();
$table->enum('gender', ['male', 'female']);
$table->date('birthdate');
$table->string('blood_type')->nullable();
$table->string('nationality');
$table->json('addresses');
$table->json('social_links');
$table->json('media_gallery');
$table->timestamps();
});
// 3. Create user_relationships table
Schema::create('user_relationships', function (Blueprint $table) {
$table->id();
$table->foreignId('guardian_user_id')->constrained('users')->cascadeOnDelete();
$table->foreignId('dependent_user_id')->constrained('users')->cascadeOnDelete();
$table->string('relationship_type'); // son, daughter, spouse, sponsor, other
$table->boolean('is_billing_contact')->default(false);
$table->timestamps();
});
// 4. Create tenants table (The Clubs)
Schema::create('tenants', function (Blueprint $table) {
$table->id();
$table->foreignId('owner_user_id')->constrained('users')->cascadeOnDelete();
$table->string('club_name');
$table->string('slug')->unique();
$table->string('logo')->nullable();
$table->decimal('gps_lat', 10, 7)->nullable();
$table->decimal('gps_long', 10, 7)->nullable();
$table->timestamps();
});
// 5. Create memberships table
Schema::create('memberships', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained('tenants')->cascadeOnDelete();
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->enum('status', ['active', 'inactive'])->default('active');
$table->timestamps();
});
// 6. Create invoices table
Schema::create('invoices', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained('tenants')->cascadeOnDelete();
$table->decimal('amount', 10, 2);
$table->string('status');
$table->date('due_date');
$table->foreignId('student_user_id')->constrained('users')->cascadeOnDelete();
$table->foreignId('payer_user_id')->constrained('users')->cascadeOnDelete();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Drop tables in reverse order
Schema::dropIfExists('invoices');
Schema::dropIfExists('memberships');
Schema::dropIfExists('tenants');
Schema::dropIfExists('user_relationships');
Schema::dropIfExists('users');
// Recreate the original users table
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
};

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->text('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};

View File

@ -0,0 +1,101 @@
@extends('layouts.app')
@section('content')
<div class="container py-4">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card shadow-sm">
<div class="card-header bg-white">
<h4 class="mb-0">Add Family Member</h4>
</div>
<div class="card-body">
<form method="POST" action="{{ route('family.store') }}">
@csrf
<div class="mb-3">
<label for="full_name" class="form-label">Full Name</label>
<input type="text" class="form-control @error('full_name') is-invalid @enderror" id="full_name" name="full_name" value="{{ old('full_name') }}" required>
@error('full_name')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="email" class="form-label">Email Address <span class="text-muted">(Optional for children)</span></label>
<input type="email" class="form-control @error('email') is-invalid @enderror" id="email" name="email" value="{{ old('email') }}">
@error('email')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="gender" class="form-label">Gender</label>
<select class="form-select @error('gender') is-invalid @enderror" id="gender" name="gender" required>
<option value="">Select Gender</option>
<option value="male" {{ old('gender') == 'male' ? 'selected' : '' }}>Male</option>
<option value="female" {{ old('gender') == 'female' ? 'selected' : '' }}>Female</option>
</select>
@error('gender')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="col-md-6">
<label for="birthdate" class="form-label">Birthdate</label>
<input type="date" class="form-control @error('birthdate') is-invalid @enderror" id="birthdate" name="birthdate" value="{{ old('birthdate') }}" required>
@error('birthdate')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="blood_type" class="form-label">Blood Type <span class="text-muted">(Optional)</span></label>
<input type="text" class="form-control @error('blood_type') is-invalid @enderror" id="blood_type" name="blood_type" value="{{ old('blood_type') }}">
@error('blood_type')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="col-md-6">
<label for="nationality" class="form-label">Nationality</label>
<input type="text" class="form-control @error('nationality') is-invalid @enderror" id="nationality" name="nationality" value="{{ old('nationality') }}" required>
@error('nationality')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="relationship_type" class="form-label">Relationship</label>
<select class="form-select @error('relationship_type') is-invalid @enderror" id="relationship_type" name="relationship_type" required>
<option value="">Select Relationship</option>
<option value="son" {{ old('relationship_type') == 'son' ? 'selected' : '' }}>Son</option>
<option value="daughter" {{ old('relationship_type') == 'daughter' ? 'selected' : '' }}>Daughter</option>
<option value="spouse" {{ old('relationship_type') == 'spouse' ? 'selected' : '' }}>Spouse</option>
<option value="sponsor" {{ old('relationship_type') == 'sponsor' ? 'selected' : '' }}>Sponsor</option>
<option value="other" {{ old('relationship_type') == 'other' ? 'selected' : '' }}>Other</option>
</select>
@error('relationship_type')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="is_billing_contact" name="is_billing_contact" value="1" {{ old('is_billing_contact') ? 'checked' : '' }}>
<label class="form-check-label" for="is_billing_contact">Is Billing Contact</label>
</div>
<div class="d-flex justify-content-between">
<a href="{{ route('family.dashboard') }}" class="btn btn-outline-secondary">Cancel</a>
<button type="submit" class="btn btn-primary">Add Family Member</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,153 @@
@extends('layouts.app')
@section('content')
<div class="container py-4">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="mb-0">My Family</h1>
<div>
<a href="{{ route('invoices.index') }}" class="btn btn-outline-primary">
<i class="bi bi-receipt"></i> All Invoices
</a>
</div>
</div>
<!-- Family Members Card Grid -->
<div class="row row-cols-1 row-cols-md-3 g-4 mb-5">
<!-- Current User Card -->
<div class="col">
<div class="card h-100 shadow-sm">
<div class="card-body text-center">
<div class="mb-3">
<img src="{{ $user->media_gallery[0] ?? 'https://via.placeholder.com/150' }}"
class="rounded-circle" alt="{{ $user->full_name }}"
width="100" height="100">
</div>
<h5 class="card-title">{{ $user->full_name }}</h5>
<p class="card-text text-muted">
Age: {{ $user->age }} ({{ $user->life_stage }})
</p>
<p class="card-text">
<small class="text-muted">{{ $user->horoscope }}</small>
</p>
<a href="{{ route('profile.edit') }}" class="btn btn-primary">
<i class="bi bi-pencil"></i> Edit Profile
</a>
</div>
</div>
</div>
<!-- Dependents Cards -->
@foreach($dependents as $relationship)
<div class="col">
<div class="card h-100 shadow-sm">
<div class="card-body text-center">
<div class="mb-3">
<img src="{{ $relationship->dependent->media_gallery[0] ?? 'https://via.placeholder.com/150' }}"
class="rounded-circle" alt="{{ $relationship->dependent->full_name }}"
width="100" height="100">
</div>
<h5 class="card-title">{{ $relationship->dependent->full_name }}</h5>
<p class="card-text text-muted">
Age: {{ $relationship->dependent->age }} ({{ $relationship->dependent->life_stage }})
</p>
<span class="badge bg-secondary">{{ ucfirst($relationship->relationship_type) }}</span>
</div>
<div class="card-footer bg-transparent border-top-0 text-center">
<div class="btn-group" role="group">
<a href="{{ route('family.edit', $relationship->dependent->id) }}" class="btn btn-sm btn-outline-secondary">
<i class="bi bi-pencil"></i> Edit
</a>
<a href="{{ route('family.show', $relationship->dependent->id) }}" class="btn btn-sm btn-outline-primary">
<i class="bi bi-eye"></i> View
</a>
</div>
</div>
</div>
</div>
@endforeach
<!-- Add New Family Member Card -->
<div class="col">
<div class="card h-100 shadow-sm border-dashed">
<a href="{{ route('family.create') }}" class="card-body text-center text-decoration-none d-flex flex-column justify-content-center align-items-center" style="height: 100%;">
<div class="mb-3">
<i class="bi bi-plus-circle" style="font-size: 3rem;"></i>
</div>
<h5 class="card-title text-muted">Add Family Member</h5>
</a>
</div>
</div>
</div>
<!-- Family Payments Table -->
<div class="card shadow-sm mb-4">
<div class="card-header bg-white">
<h4 class="mb-0">Family Payments</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Student Name</th>
<th>Class/Package</th>
<th>Amount</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@forelse($familyInvoices as $invoice)
<tr>
<td>{{ $invoice->student->full_name }}</td>
<td>{{ $invoice->tenant->club_name }}</td>
<td>${{ number_format($invoice->amount, 2) }}</td>
<td>
@if($invoice->status === 'paid')
<span class="badge bg-success">Paid</span>
@elseif($invoice->status === 'pending')
<span class="badge bg-warning text-dark">Pending</span>
@else
<span class="badge bg-danger">Overdue</span>
@endif
</td>
<td>
<a href="{{ route('invoices.show', $invoice->id) }}" class="btn btn-sm btn-outline-primary">
<i class="bi bi-eye"></i> View
</a>
@if($invoice->status !== 'paid')
<a href="{{ route('invoices.pay', $invoice->id) }}" class="btn btn-sm btn-success">
<i class="bi bi-credit-card"></i> Pay
</a>
@endif
</td>
</tr>
@empty
<tr>
<td colspan="5" class="text-center py-4">
<p class="text-muted mb-0">No payments due at this time.</p>
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
<div class="card-footer bg-white d-flex justify-content-end">
@if(count($familyInvoices->where('status', '!=', 'paid')) > 0)
<a href="{{ route('invoices.pay-all') }}" class="btn btn-success">
<i class="bi bi-credit-card"></i> Pay All
</a>
@endif
</div>
</div>
</div>
<style>
.border-dashed {
border-style: dashed !important;
border-width: 2px !important;
border-color: #dee2e6 !important;
}
</style>
@endsection

View File

@ -0,0 +1,130 @@
@extends('layouts.app')
@section('content')
<div class="container py-4">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card shadow-sm">
<div class="card-header bg-white">
<h4 class="mb-0">Edit Family Member</h4>
</div>
<div class="card-body">
<form method="POST" action="{{ route('family.update', $relationship->dependent->id) }}">
@csrf
@method('PUT')
<div class="mb-3">
<label for="full_name" class="form-label">Full Name</label>
<input type="text" class="form-control @error('full_name') is-invalid @enderror" id="full_name" name="full_name" value="{{ old('full_name', $relationship->dependent->full_name) }}" required>
@error('full_name')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="email" class="form-label">Email Address <span class="text-muted">(Optional for children)</span></label>
<input type="email" class="form-control @error('email') is-invalid @enderror" id="email" name="email" value="{{ old('email', $relationship->dependent->email) }}">
@error('email')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="gender" class="form-label">Gender</label>
<select class="form-select @error('gender') is-invalid @enderror" id="gender" name="gender" required>
<option value="">Select Gender</option>
<option value="male" {{ old('gender', $relationship->dependent->gender) == 'male' ? 'selected' : '' }}>Male</option>
<option value="female" {{ old('gender', $relationship->dependent->gender) == 'female' ? 'selected' : '' }}>Female</option>
</select>
@error('gender')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="col-md-6">
<label for="birthdate" class="form-label">Birthdate</label>
<input type="date" class="form-control @error('birthdate') is-invalid @enderror" id="birthdate" name="birthdate" value="{{ old('birthdate', $relationship->dependent->birthdate->format('Y-m-d')) }}" required>
@error('birthdate')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="blood_type" class="form-label">Blood Type <span class="text-muted">(Optional)</span></label>
<input type="text" class="form-control @error('blood_type') is-invalid @enderror" id="blood_type" name="blood_type" value="{{ old('blood_type', $relationship->dependent->blood_type) }}">
@error('blood_type')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="col-md-6">
<label for="nationality" class="form-label">Nationality</label>
<input type="text" class="form-control @error('nationality') is-invalid @enderror" id="nationality" name="nationality" value="{{ old('nationality', $relationship->dependent->nationality) }}" required>
@error('nationality')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="relationship_type" class="form-label">Relationship</label>
<select class="form-select @error('relationship_type') is-invalid @enderror" id="relationship_type" name="relationship_type" required>
<option value="">Select Relationship</option>
<option value="son" {{ old('relationship_type', $relationship->relationship_type) == 'son' ? 'selected' : '' }}>Son</option>
<option value="daughter" {{ old('relationship_type', $relationship->relationship_type) == 'daughter' ? 'selected' : '' }}>Daughter</option>
<option value="spouse" {{ old('relationship_type', $relationship->relationship_type) == 'spouse' ? 'selected' : '' }}>Spouse</option>
<option value="sponsor" {{ old('relationship_type', $relationship->relationship_type) == 'sponsor' ? 'selected' : '' }}>Sponsor</option>
<option value="other" {{ old('relationship_type', $relationship->relationship_type) == 'other' ? 'selected' : '' }}>Other</option>
</select>
@error('relationship_type')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="is_billing_contact" name="is_billing_contact" value="1" {{ old('is_billing_contact', $relationship->is_billing_contact) ? 'checked' : '' }}>
<label class="form-check-label" for="is_billing_contact">Is Billing Contact</label>
</div>
<div class="d-flex justify-content-between">
<a href="{{ route('family.dashboard') }}" class="btn btn-outline-secondary">Cancel</a>
<div>
<button type="button" class="btn btn-danger me-2" data-bs-toggle="modal" data-bs-target="#deleteModal">
Remove
</button>
<button type="submit" class="btn btn-primary">Update Family Member</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Delete Confirmation Modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteModalLabel">Confirm Removal</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Are you sure you want to remove {{ $relationship->dependent->full_name }} from your family?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<form action="{{ route('family.destroy', $relationship->dependent->id) }}" method="POST">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Remove</button>
</form>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,157 @@
@extends('layouts.app')
@section('content')
<div class="container py-4">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card shadow-sm">
<div class="card-header bg-white d-flex justify-content-between align-items-center">
<h4 class="mb-0">Family Member Details</h4>
<a href="{{ route('family.dashboard') }}" class="btn btn-outline-secondary btn-sm">
<i class="bi bi-arrow-left"></i> Back to Family
</a>
</div>
<div class="card-body">
<div class="text-center mb-4">
<img src="{{ $relationship->dependent->media_gallery[0] ?? 'https://via.placeholder.com/150' }}"
class="rounded-circle mb-3" alt="{{ $relationship->dependent->full_name }}"
width="120" height="120">
<h3>{{ $relationship->dependent->full_name }}</h3>
<span class="badge bg-secondary">{{ ucfirst($relationship->relationship_type) }}</span>
@if($relationship->is_billing_contact)
<span class="badge bg-info ms-2">Billing Contact</span>
@endif
</div>
<div class="row">
<div class="col-md-6 mb-3">
<h6 class="text-muted">Age</h6>
<p>{{ $relationship->dependent->age }} years ({{ $relationship->dependent->life_stage }})</p>
</div>
<div class="col-md-6 mb-3">
<h6 class="text-muted">Birthdate</h6>
<p>{{ $relationship->dependent->birthdate->format('F j, Y') }}</p>
</div>
<div class="col-md-6 mb-3">
<h6 class="text-muted">Gender</h6>
<p>{{ ucfirst($relationship->dependent->gender) }}</p>
</div>
<div class="col-md-6 mb-3">
<h6 class="text-muted">Horoscope</h6>
<p>{{ $relationship->dependent->horoscope }}</p>
</div>
<div class="col-md-6 mb-3">
<h6 class="text-muted">Nationality</h6>
<p>{{ $relationship->dependent->nationality }}</p>
</div>
<div class="col-md-6 mb-3">
<h6 class="text-muted">Blood Type</h6>
<p>{{ $relationship->dependent->blood_type ?? 'Not specified' }}</p>
</div>
@if($relationship->dependent->email)
<div class="col-md-6 mb-3">
<h6 class="text-muted">Email</h6>
<p>{{ $relationship->dependent->email }}</p>
</div>
@endif
@if($relationship->dependent->mobile)
<div class="col-md-6 mb-3">
<h6 class="text-muted">Mobile</h6>
<p>{{ $relationship->dependent->mobile }}</p>
</div>
@endif
</div>
<div class="d-flex justify-content-end mt-3">
<a href="{{ route('family.edit', $relationship->dependent->id) }}" class="btn btn-primary">
<i class="bi bi-pencil"></i> Edit
</a>
</div>
</div>
</div>
<!-- Memberships -->
<div class="card shadow-sm mt-4">
<div class="card-header bg-white">
<h5 class="mb-0">Club Memberships</h5>
</div>
<div class="card-body">
@if($relationship->dependent->memberClubs->count() > 0)
<div class="list-group">
@foreach($relationship->dependent->memberClubs as $club)
<div class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
<div>
<h6 class="mb-1">{{ $club->club_name }}</h6>
<small class="text-muted">Status: {{ ucfirst($club->pivot->status) }}</small>
</div>
<span class="badge bg-{{ $club->pivot->status === 'active' ? 'success' : 'secondary' }} rounded-pill">
{{ ucfirst($club->pivot->status) }}
</span>
</div>
@endforeach
</div>
@else
<p class="text-center text-muted my-4">No club memberships found.</p>
@endif
</div>
</div>
<!-- Invoices -->
<div class="card shadow-sm mt-4">
<div class="card-header bg-white">
<h5 class="mb-0">Recent Invoices</h5>
</div>
<div class="card-body">
@if($relationship->dependent->studentInvoices->count() > 0)
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Club</th>
<th>Amount</th>
<th>Status</th>
<th>Due Date</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($relationship->dependent->studentInvoices->take(5) as $invoice)
<tr>
<td>{{ $invoice->tenant->club_name }}</td>
<td>${{ number_format($invoice->amount, 2) }}</td>
<td>
@if($invoice->status === 'paid')
<span class="badge bg-success">Paid</span>
@elseif($invoice->status === 'pending')
<span class="badge bg-warning text-dark">Pending</span>
@else
<span class="badge bg-danger">Overdue</span>
@endif
</td>
<td>{{ $invoice->due_date->format('M j, Y') }}</td>
<td>
<a href="{{ route('invoices.show', $invoice->id) }}" class="btn btn-sm btn-outline-primary">
View
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@if($relationship->dependent->studentInvoices->count() > 5)
<div class="text-center mt-3">
<a href="{{ route('invoices.index') }}" class="btn btn-outline-primary btn-sm">
View All Invoices
</a>
</div>
@endif
@else
<p class="text-center text-muted my-4">No invoices found.</p>
@endif
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,97 @@
@extends('layouts.app')
@section('content')
<div class="container py-4">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1 class="mb-0">My Invoices</h1>
</div>
<div class="card shadow-sm">
<div class="card-header bg-white d-flex justify-content-between align-items-center">
<h4 class="mb-0">All Invoices</h4>
<div class="btn-group" role="group">
<button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-funnel"></i> Filter
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li><a class="dropdown-item" href="{{ route('invoices.index') }}">All</a></li>
<li><a class="dropdown-item" href="{{ route('invoices.index', ['status' => 'pending']) }}">Pending</a></li>
<li><a class="dropdown-item" href="{{ route('invoices.index', ['status' => 'paid']) }}">Paid</a></li>
<li><a class="dropdown-item" href="{{ route('invoices.index', ['status' => 'overdue']) }}">Overdue</a></li>
</ul>
</div>
</div>
<div class="card-body">
@if(session('success'))
<div class="alert alert-success alert-dismissible fade show" role="alert">
{{ session('success') }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif
@if($invoices->count() > 0)
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Invoice #</th>
<th>Student</th>
<th>Club</th>
<th>Amount</th>
<th>Status</th>
<th>Due Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($invoices as $invoice)
<tr>
<td>{{ $invoice->id }}</td>
<td>{{ $invoice->student->full_name }}</td>
<td>{{ $invoice->tenant->club_name }}</td>
<td>${{ number_format($invoice->amount, 2) }}</td>
<td>
@if($invoice->status === 'paid')
<span class="badge bg-success">Paid</span>
@elseif($invoice->status === 'pending')
<span class="badge bg-warning text-dark">Pending</span>
@else
<span class="badge bg-danger">Overdue</span>
@endif
</td>
<td>{{ $invoice->due_date->format('M j, Y') }}</td>
<td>
<div class="btn-group" role="group">
<a href="{{ route('invoices.show', $invoice->id) }}" class="btn btn-sm btn-outline-primary">
<i class="bi bi-eye"></i> View
</a>
@if($invoice->status !== 'paid')
<a href="{{ route('invoices.pay', $invoice->id) }}" class="btn btn-sm btn-success">
<i class="bi bi-credit-card"></i> Pay
</a>
@endif
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@else
<div class="text-center py-5">
<i class="bi bi-receipt" style="font-size: 3rem;"></i>
<h4 class="mt-3">No Invoices Found</h4>
<p class="text-muted">There are no invoices matching your criteria.</p>
</div>
@endif
</div>
@if($invoices->where('status', '!=', 'paid')->count() > 0)
<div class="card-footer bg-white d-flex justify-content-end">
<a href="{{ route('invoices.pay-all') }}" class="btn btn-success">
<i class="bi bi-credit-card"></i> Pay All
</a>
</div>
@endif
</div>
</div>
@endsection

View File

@ -0,0 +1,100 @@
@extends('layouts.app')
@section('content')
<div class="container py-4">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card shadow-sm">
<div class="card-header bg-white d-flex justify-content-between align-items-center">
<h4 class="mb-0">Invoice #{{ $invoice->id }}</h4>
<a href="{{ route('invoices.index') }}" class="btn btn-outline-secondary btn-sm">
<i class="bi bi-arrow-left"></i> Back to Invoices
</a>
</div>
<div class="card-body">
@if(session('success'))
<div class="alert alert-success alert-dismissible fade show" role="alert">
{{ session('success') }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif
<div class="row mb-4">
<div class="col-md-6">
<h5>Billed To</h5>
<p class="mb-1">{{ Auth::user()->full_name }}</p>
<p class="mb-1">{{ Auth::user()->email }}</p>
@if(Auth::user()->mobile)
<p class="mb-0">{{ Auth::user()->mobile }}</p>
@endif
</div>
<div class="col-md-6 text-md-end">
<h5>Invoice Details</h5>
<p class="mb-1">Invoice #: {{ $invoice->id }}</p>
<p class="mb-1">Due Date: {{ $invoice->due_date->format('F j, Y') }}</p>
<p class="mb-0">
Status:
@if($invoice->status === 'paid')
<span class="badge bg-success">Paid</span>
@elseif($invoice->status === 'pending')
<span class="badge bg-warning text-dark">Pending</span>
@else
<span class="badge bg-danger">Overdue</span>
@endif
</p>
</div>
</div>
<div class="row mb-4">
<div class="col-md-6">
<h5>Club Information</h5>
<p class="mb-1">{{ $invoice->tenant->club_name }}</p>
<p class="mb-0">{{ $invoice->tenant->owner->full_name }} (Owner)</p>
</div>
<div class="col-md-6 text-md-end">
<h5>Student Information</h5>
<p class="mb-1">{{ $invoice->student->full_name }}</p>
<p class="mb-0">Age: {{ $invoice->student->age }} ({{ $invoice->student->life_stage }})</p>
</div>
</div>
<div class="table-responsive mb-4">
<table class="table table-bordered">
<thead class="table-light">
<tr>
<th>Description</th>
<th class="text-end">Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>Club Membership Fee - {{ $invoice->tenant->club_name }}</td>
<td class="text-end">${{ number_format($invoice->amount, 2) }}</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Total</th>
<th class="text-end">${{ number_format($invoice->amount, 2) }}</th>
</tr>
</tfoot>
</table>
</div>
<div class="d-flex justify-content-end">
@if($invoice->status !== 'paid')
<a href="{{ route('invoices.pay', $invoice->id) }}" class="btn btn-success">
<i class="bi bi-credit-card"></i> Pay Now
</a>
@else
<button class="btn btn-outline-success" disabled>
<i class="bi bi-check-circle"></i> Paid
</button>
@endif
</div>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,128 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Club SaaS') }}</title>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
<!-- Custom Styles -->
<style>
body {
font-family: 'Inter', sans-serif;
background-color: #f8f9fa;
}
.navbar-brand {
font-weight: 600;
}
.nav-link {
font-weight: 500;
}
.card {
border-radius: 10px;
border: none;
}
.card-header {
border-radius: 10px 10px 0 0 !important;
border-bottom: none;
}
.btn {
border-radius: 5px;
padding: 0.5rem 1rem;
font-weight: 500;
}
.btn-primary {
background-color: #0d6efd;
border-color: #0d6efd;
}
.btn-primary:hover {
background-color: #0b5ed7;
border-color: #0a58ca;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'Club SaaS') }}
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!-- Left Side Of Navbar -->
<ul class="navbar-nav me-auto">
@auth
<li class="nav-item">
<a class="nav-link" href="{{ route('family.dashboard') }}">My Family</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('invoices.index') }}">Invoices</a>
</li>
@endauth
</ul>
<!-- Right Side Of Navbar -->
<ul class="navbar-nav ms-auto">
<!-- Authentication Links -->
@guest
@if (Route::has('login'))
<li class="nav-item">
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
</li>
@endif
@if (Route::has('register'))
<li class="nav-item">
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
</li>
@endif
@else
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->full_name }}
</a>
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('profile.edit') }}">
{{ __('Profile') }}
</a>
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
@csrf
</form>
</div>
</li>
@endguest
</ul>
</div>
</div>
</nav>
<main>
@yield('content')
</main>
<!-- Bootstrap JS Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

8
routes/api.php Normal file
View File

@ -0,0 +1,8 @@
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::get('/user', function (Request $request) {
return $request->user();
})->middleware('auth:sanctum');

View File

@ -1,7 +1,26 @@
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\FamilyController;
use App\Http\Controllers\InvoiceController;
Route::get('/', function () {
return view('welcome');
});
// Family routes
Route::middleware(['auth'])->group(function () {
Route::get('/family', [FamilyController::class, 'dashboard'])->name('family.dashboard');
Route::get('/family/create', [FamilyController::class, 'create'])->name('family.create');
Route::post('/family', [FamilyController::class, 'store'])->name('family.store');
Route::get('/family/{id}', [FamilyController::class, 'show'])->name('family.show');
Route::get('/family/{id}/edit', [FamilyController::class, 'edit'])->name('family.edit');
Route::put('/family/{id}', [FamilyController::class, 'update'])->name('family.update');
Route::delete('/family/{id}', [FamilyController::class, 'destroy'])->name('family.destroy');
// Invoice routes
Route::get('/invoices', [InvoiceController::class, 'index'])->name('invoices.index');
Route::get('/invoices/{id}', [InvoiceController::class, 'show'])->name('invoices.show');
Route::get('/invoices/{id}/pay', [InvoiceController::class, 'pay'])->name('invoices.pay');
Route::get('/invoices/pay-all', [InvoiceController::class, 'payAll'])->name('invoices.pay-all');
});