feat: Implement Ledgers CRUD

This commit is contained in:
Daan Meijer
2026-06-15 00:33:32 +02:00
parent 647a708160
commit 4fe89f0600
7 changed files with 290 additions and 4 deletions
+77
View File
@@ -0,0 +1,77 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreLedgerRequest;
use App\Models\Dynamic;
use App\Models\Ledger;
use Illuminate\Http\Request;
use Inertia\Inertia;
class LedgerController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(StoreLedgerRequest $request, Dynamic $dynamic)
{
$dynamic->ledgers()->create($request->validated());
return redirect()->route('dynamics.show', $dynamic);
}
/**
* Display the specified resource.
*/
public function show(Dynamic $dynamic, Ledger $ledger)
{
$this->authorize('view', $ledger);
$ledger->load('mutations.user');
return Inertia::render('Ledgers/Show', [
'dynamic' => $dynamic,
'ledger' => $ledger,
]);
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Ledger $ledger)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, Ledger $ledger)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Ledger $ledger)
{
//
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use App\Models\Dynamic;
class StoreLedgerRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
$dynamic = $this->route('dynamic');
return $dynamic && $this->user()->can('view', $dynamic);
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
*/
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'rules' => ['nullable', 'string'],
];
}
}