When I am testing my REST API from postman, it gives me error "Trying to get property of non-object". Because there is no session in postman. If there is browser then session is created but not in postman. Can anyone give alternate solutions of Auth::user()
This is my route
Route::post('playlist/{id}/follow', 'PlaylistController@follow');
This is my code snippet.
public function follow($id)
{
$user = $this->model->findOrFail($id);
if ($user->id != Auth::user()->id) {
Auth::user()->followedUsers()->attach($id);
}
}
via Rahul Chauhan