ledgerrz/app/Http/Controllers/DynamicController.php
Daan Meijer 06cd53fe91
Some checks failed
linter / quality (push) Failing after 1m8s
tests / ci (8.3) (push) Failing after 48s
tests / ci (8.4) (push) Failing after 1m6s
tests / ci (8.5) (push) Failing after 1m4s
added invitations
2026-06-16 16:29:17 +02:00

97 lines
2.2 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreDynamicRequest;
use App\Models\Dynamic;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Http\Request;
use Inertia\Inertia;
use App\Services\ActivityService;
class DynamicController extends Controller
{
use AuthorizesRequests;
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
return Inertia::render('Dynamics/Index', [
'dynamics' => $request->user()->dynamics()->get(),
]);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return Inertia::render('Dynamics/Create');
}
/**
* Store a newly created resource in storage.
*/
public function store(StoreDynamicRequest $request)
{
$dynamic = Dynamic::create($request->validated());
$dynamic->participants()->attach($request->user()->id, ['role' => 'owner']);
return redirect()->route('dynamics.show', $dynamic);
}
/**
* Display the specified resource.
*/
public function show(Request $request, Dynamic $dynamic, ActivityService $activityService)
{
$this->authorize('view', $dynamic);
$activityService->updateCursor($request->user(), $dynamic);
$dynamic->load([
'ledgers.media',
'participants',
'chat.messages.user',
'chat.messages.media'
]);
$isOwner = $dynamic->participants()
->where('user_id', $request->user()->id)
->where('role', 'owner')
->exists();
return Inertia::render('Dynamics/Show', [
'dynamic' => $dynamic,
'isOwner' => $isOwner,
]);
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Dynamic $dynamic)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, Dynamic $dynamic)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Dynamic $dynamic)
{
//
}
}