diff --git a/app/Http/Controllers/MutationController.php b/app/Http/Controllers/MutationController.php index 8bf5993..39e162c 100644 --- a/app/Http/Controllers/MutationController.php +++ b/app/Http/Controllers/MutationController.php @@ -72,6 +72,21 @@ class MutationController extends Controller return redirect()->route('dynamics.ledgers.show', [$dynamic, $ledger]); } + public function show(Request $request, Dynamic $dynamic, Ledger $ledger, Mutation $mutation) + { + $this->authorize('view', $mutation); + + $mutation->load('user', 'ledger', 'media', 'chat.messages.user'); + $dynamic = $mutation->ledger->dynamic; + + $dynamic->load('participants'); + + return inertia('Mutations/Show', [ + 'mutation' => $mutation, + 'dynamic' => $dynamic, + ]); + } + public function update(Request $request, Dynamic $dynamic, Ledger $ledger, Mutation $mutation) { $this->authorize('update', $mutation); diff --git a/app/Policies/MutationPolicy.php b/app/Policies/MutationPolicy.php index 8579a0b..691125e 100644 --- a/app/Policies/MutationPolicy.php +++ b/app/Policies/MutationPolicy.php @@ -8,6 +8,14 @@ use App\Models\User; class MutationPolicy { + /** + * Determine whether the user can view the mutation. + */ + public function view(User $user, Mutation $mutation): bool + { + return $user->can('view', $mutation->ledger); + } + /** * Determine whether the user can create mutations. */ @@ -18,12 +26,6 @@ class MutationPolicy return $dynamic->participants()->where('user_id', $user->id)->exists(); } - public function view(User $user, Mutation $mutation): bool - { - $ledger = $mutation->ledger; - return $user->can('view', $ledger); - } - /** * Determine whether the user can update the mutation. */ diff --git a/resources/js/components/MutationList.vue b/resources/js/components/MutationList.vue index ba8bd74..4fff8c8 100644 --- a/resources/js/components/MutationList.vue +++ b/resources/js/components/MutationList.vue @@ -1,64 +1,22 @@ + + + +