src/Discussion/Discussion.php
public function state(User $user = null)
    {
        $user = $user ?: static::$stateUser;

        return $this->hasOne(UserState::class)->where('user_id', $user ? $user->id : null);
    }
public function state(User $user = null)
    {
        $user = $user ?: static::$stateUser;

        return $this->hasOne(UserState::class)->where('user_id', $user ? $user->id : null);
    }
public function state ( User $ user = null ) { $ user = $ user ? : static :: $ stateUser ; return $ this -> hasOne ( UserState :: class ) -> where ( 'user_id' , $ user ? $ user -> id : null ) ; }
Define the relationship with the discussion's state for a particular
user.

If no user is passed (i.e. in the case of eager loading the 'state'
relation), then the static `$stateUser` property is used.

@see Discussion::setStateUser()

@param User|null $user
@return \Illuminate\Database\Eloquent\Relations\HasOne
Define the relationship with the discussion s state for a particular user .