DEV Community

Discussion on: Making Api CRUD(Create,Read,Update,Delete) with Laravel 8 n API Authentication with sanctum

Collapse
 
saanchitapaul profile image
Sanchita Paul • Edited

I am getting error during logout. I didn't use any relation ,then why it's showing MorphMany error ?

<title>๐Ÿงจ Call to undefined method Illuminate\Database\Eloquent\Relations\MorphMany::logout()</title>

Collapse
 
tanzimibthesam profile image
Tanzim Ibthesam

Hello Sanchita can you please check whether you have written the logout method in Controller properly.Thanks

Collapse
 
saanchitapaul profile image
Sanchita Paul

I solved this using delete method. It was showing error using logout.

public function logout(Request $request){
//auth()->user()->tokens()->logout();
auth()->user()->currentAccessToken()->delete();
return [
'message'=>'You're logged out'
];
}

Thread Thread
 
tanzimibthesam profile image
Tanzim Ibthesam

Thanks