The detach() method should work.
To help you it would be helpful to know your models and relationships.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hello , i have 2 issues here with has many relationship , first i want to delete on record not all so i use detach
public function inviteDestroy(Round_invitation $invitation, $id)
{
$invitation->invitations()->detach($id);
return back()->with('success', "Invitation Has Been Deleted");
}
but i get error
Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::detach()
so after search i found the detach for pivot tables but to delete use where , so what's right way ? , after that i using update like that
Form action="{{route('invitations.invite.updated',$province_invitation)}}">
And Controller
public function inviteUpdate(InvitationUpdateRequest $request, Invitation $province_invitation)
{
$attributes = $request->validated();
$province_invitation->update($attributes);
return back()->with('success', "Invitation Has Been Updated");
}
so here i call the all model to update where id was sent from the blade normally but i think the right way is update from relation but after many search i don't find any way to update one record
The Route-Model binding is not working correctly because : +exists: false - you are just getting a new instance of Round_invitation (which has no id).
Make sure that the route URL wildcard {round} matches the controller action parameter $round:
Route::delete('/round/{round}', [WhateverController::class, 'inviteDestroy']);
public function inviteDestroy(Round_invitation $round, $id)
Please or to participate in this conversation.