Hi,
i store an relation in the user model, but as soon as i save the authenticated user, a new login always response "Unauthenticated". This is the store method:
$this->authorize('create', Organization::class);
$organization = Organization::create($request->validated());
Auth::user()->organization()->associate($organization)->save();
This are the relation to the organization in the user-model:
public function organization(): BelongsTo
{
return $this->belongsTo(Organization::class, 'organization_id');
}
and the relation in the organization-model to the user:
public function users(): HasMany
{
return $this->hasMany(User::class);
}
Things like:
User::find(Auth::user()->getAuthIdentifier())->first()->update(['organization_id' => $organization->id]);
Auth::user()->forceFill(['organization' => $organization->id])->save()
brings the same effect.
I dump after save() the user with dd(Auth::user()) and i see in the changes array, that the password is in it. Maybe this is the problem, but i don't know, the hash is the same in the database before and after save.
Anybody an idea?
Cheers Ralf
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community