Error Passing Values From Function To A Controller As An Object

I have the following code:

        $storedToken = getStoredToken();

         * Verify if the stored token has expired.
        if ($storedToken->hasExpired()) {

             * If the stored token has expired, then you request a new one.
            $newToken = $provider->getAccessToken('refresh_token', [
                'refresh_token' => $storedToken->getRefreshToken()

In my db I have the following fields:

  • token
  • refreshtoken
  • expires

I tried:

public function StoredToken(){
    $user = Auth::user(); //data is on users table.
    return $refreshtoken = $user->melirefreshtoken; //eg.


But with no success. I cannot find the way to create a function to create an object passing all the information.

Right now I received error:

Call to undefined function App\Http\Controllers\getStoredToken()

any help appreciated.



The root of the problem seems to be this line:

$storedToken = getStoredToken();
//             ^^^^^^^^^^^^^^^^^

If you are trying to call a function from another function (from the same class).. add this:

$storedToken = $this->getStoredToken();
//             ^^^^^^^