over naar uuids, policies, predefined mutations aan kunnen passen
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\StoreDynamicRequest;
|
||||
use App\Http\Requests\UpdateDynamicRequest;
|
||||
use App\Http\Resources\DynamicResource;
|
||||
use App\Http\Resources\LedgerResource;
|
||||
use App\Http\Resources\MessageResource;
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Models\Dynamic;
|
||||
use App\Services\ActivityService;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
@@ -19,7 +21,7 @@ class DynamicController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
return Inertia::render('Dynamics/Index', [
|
||||
'dynamics' => $request->user()->dynamics()->get(),
|
||||
'dynamics' => DynamicResource::collection($request->user()->dynamics()->get()),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -54,15 +56,14 @@ class DynamicController extends Controller
|
||||
|
||||
$dynamic->load(['ledgers.media', 'participants', 'chat']);
|
||||
|
||||
$isOwner = $dynamic->participants()
|
||||
->where('user_id', $request->user()->id)
|
||||
->where('role', 'owner')
|
||||
->exists();
|
||||
|
||||
return Inertia::render('Dynamics/Show', [
|
||||
'dynamic' => $dynamic,
|
||||
'isOwner' => $isOwner,
|
||||
'messages' => $dynamic->chat->messages()->with(['user', 'media'])->latest()->paginate(20),
|
||||
'dynamic' => new DynamicResource($dynamic),
|
||||
'ledgers' => LedgerResource::collection($dynamic->ledgers),
|
||||
'participants' => UserResource::collection($dynamic->participants),
|
||||
'messages' => MessageResource::collection($dynamic->chat->messages()->with(['user', 'media'])->latest()->paginate(20)),
|
||||
'can' => [
|
||||
'update' => $request->user()->can('update', $dynamic),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -70,7 +71,7 @@ class DynamicController extends Controller
|
||||
{
|
||||
$this->authorize('view', $dynamic);
|
||||
|
||||
return $dynamic->chat->messages()->with(['user', 'media'])->latest()->paginate(20);
|
||||
return MessageResource::collection($dynamic->chat->messages()->with(['user', 'media'])->latest()->paginate(20));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +82,7 @@ class DynamicController extends Controller
|
||||
$this->authorize('update', $dynamic);
|
||||
|
||||
return Inertia::render('Dynamics/Settings', [
|
||||
'dynamic' => $dynamic,
|
||||
'dynamic' => new DynamicResource($dynamic),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user