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,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