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:
1 parent
f27b5abf02
commit
4a7353e3fc
23 files changed
+1871
-2
No files matched your search
@@ -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.');
|
||||
}
|
||||
}
|
||||
@@ -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.');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user