better system messages, display name relocation
This commit is contained in:
@@ -3,10 +3,40 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Dynamic;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class ParticipantController extends Controller
|
||||
{
|
||||
public function show(Request $request, Dynamic $dynamic, User $user)
|
||||
{
|
||||
// Ensure both the authenticated user and the target user are in the dynamic
|
||||
if (!$dynamic->participants()->where('user_id', $request->user()->id)->exists()) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$participant = $dynamic->participants()->where('user_id', $user->id)->firstOrFail();
|
||||
|
||||
$mutations = $user->mutations()
|
||||
->whereHas('ledger', fn($query) => $query->where('dynamic_id', $dynamic->id))
|
||||
->with('ledger')
|
||||
->latest('id')
|
||||
->take(10)
|
||||
->get();
|
||||
|
||||
return Inertia::render('Participants/Show', [
|
||||
'dynamic' => $dynamic,
|
||||
'participant' => [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'display_name' => $participant->pivot->display_name,
|
||||
'role' => $participant->pivot->role,
|
||||
],
|
||||
'mutations' => $mutations,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Dynamic $dynamic)
|
||||
{
|
||||
$request->validate([
|
||||
|
||||
Reference in New Issue
Block a user