Our Black Friday sale is now live! All individual subscriptions are 50% OFF. This week only!

azular23

azular23

Member Since 3 Months Ago

Experience Points
440
Total
Experience

4,560 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
3
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
440 XP
Oct
05
1 month ago
Activity icon

Replied to Syntax Error, Unexpected 'SlugOptions' In Spatie/Laravel-sluggable

@sinnbeck thank you for your help, I just also configure one file in my sites-available by navigating through

/etc/nginx/sites-available/

then i just changed the PHP-FPM socket inside the file located inside the location block location ~ \.php$

from

location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
}

to

location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
}

then i reload the server.

Oct
02
1 month ago
Activity icon

Replied to Syntax Error, Unexpected 'SlugOptions' In Spatie/Laravel-sluggable

@sinnbeck Oh ok I see, the webserver is running on Nginx.

Activity icon

Replied to Syntax Error, Unexpected 'SlugOptions' In Spatie/Laravel-sluggable

@laracoft Sorry but something like this?

ParseError
syntax error, unexpected 'SlugOptions' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) 
Activity icon

Replied to Syntax Error, Unexpected 'SlugOptions' In Spatie/Laravel-sluggable

Hi, the error occured when I used hasSlug on one of my model


use Spatie\Sluggable\SlugOptions;

class Listofgood extends Model
{
    use SoftDeletes;
    use HasSlug; <---- *Right here*

}

And on my server phpinfo my php version is 7.2.8 which is kinda weird when i try to run php -v its 7.4.10

Activity icon

Started a new Conversation Syntax Error, Unexpected 'SlugOptions' In Spatie/Laravel-sluggable

Hi guys, im really confused on this error

syntax error, unexpected 'SlugOptions' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)

about spatie/laravel-sluggable package. I did some couple of research and some people stated is to check the composer and php version which in my case I have the 7.4 version. This error only occurs on my dev server but it works perfectly on my local development environment and both have the same version of every packages.

composer.json

"require": {
        "php": "^7.4",
        "ext-curl": "*",
        "ext-json": "*",
        "darkaonline/l5-swagger": "^7.0",
        "doctrine/dbal": "^2.10",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^1.0",
        "guzzlehttp/guzzle": "^6.5",
        "laravel/framework": "^7.0",
        "laravel/passport": "^9.2",
        "laravel/socialite": "^5.0",
        "laravel/tinker": "^2.0",
        "laravel/ui": "^2.0",
        "laravolt/avatar": "^3.2",
        "socialiteproviders/facebook": "^1.0",
        "spatie/laravel-sluggable": "^2.5"
},

My local php version

PHP 7.4.8 (cli) (built: Jul  9 2020 11:30:39) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Server php version

PHP 7.4.10 (cli) (built: Sep  9 2020 06:36:14) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
Sep
22
2 months ago
Activity icon

Started a new Conversation Twitter Socialite

Hi guys, I'm trying to integrate Laravel's socialite authentication specifically for twitter but I got no luck trying to make it work. Other providers like GitHub, Facebook, and Google works like a charm except twitter. I'm currently using Vue SPA for frontend and laravel for the backend. The Vue files are in a different folder so the way I access socialite is through laravel's API. Sorry this is my first time using Laravel and Vue. Any help is appreciated.

Here is my socialite controller

 public function redirectToProvider($provider)
    {
        if ($provider == 'twitter') {
            $url = Socialite::driver('twitter')->redirect()->getTargetUrl();
        } else {
            $url = Socialite::driver($provider)->stateless()->redirect()->getTargetUrl();
        }

        return response()->json([
            'url' => $url
        ]);
    }

    public function handleProviderCallback(Request $request, $provider)
    {
        try {

            if ($provider == 'twitter' && $request->has(['oauth_token', 'oauth_verifier'])) {
                $user = Socialite::driver('twitter')->user();
            } else {
                $user = Socialite::driver($provider)->stateless()->user();
            }

            if(!$user->token) {
                return response()->json([
                    'error' => true,
                    'message' => `Unable to login user to ${$provider}`
                ],201);
            }
            
            // $user->token;
    
            // check if user exists or else insert new user information to the database.
            $create_user = User::firstOrCreate(
                ['email' => $user->getEmail()],
                [
                    'name' => $user->getName(),
                    'avatar' => $user->getAvatar(),
                    'uuid' => Str::uuid(),
                ]
            );
    
            if($create_user) {
                $success['nbrl_access_token'] = $create_user->createToken('authToken')->accessToken;
                $success['name'] = $create_user->name;
                $success['email'] = $user->email;
                $success['error'] = false;
                $success['message'] = 'User authenticated';
                
                return response()->json($success, 201);
            }
        } catch (\Exception $e) {
            return response()->json([
                'error' => true,
                'message' => $e->getMessage()
            ], 422);
        }
        // $user = Socialite::driver('twitter')->userFromTokenAndSecret($token, $secret);

        // dd($user);
    }

My twitter callback URL is

http://localhost:8080/login/twitter/callback

which is my one of my Vue routes

Inside of my Vue login/twitter/callback route

async loginProvider () {
      try {
        var params = {}

        if (this.$route.query.code) {
          params = {
            code: this.$route.query.code
          }
        } else {
          params = {
            oauth_token: this.$route.query.oauth_token,
            oauth_verifier: this.$route.query.oauth_verifier
          }
        }

        const authenticate = await this.authenticateProviderCallback({
          provider: this.$route.params.provider,
          // code: this.$route.query.code
          params
        })
        this.setLoader(true)
        if (authenticate) {
          console.log('Authenticate provider callback', authenticate)
          this.setLoader(false)
          this.$router.push({ name: 'dashboard' })
        }
      } catch (error) {
        console.log('error logging in', error)
      }
    }

and my Vuex store.

const actions = {
  authenticateProviderCallback ({ commit, dispatch }, payload) {
    return new Promise((resolve, reject) => {
      console.log('params', payload)
      axios({
        method: 'get',
        url: process.env.API + `/user/login/${payload.provider}/callback`,
        params: payload.params
      }).then((response) => {
        console.log('Provider callback', response)
        if (response.data.nbrl_access_token && !response.data.error) {
          LocalStorage.set('nbrl_access_token', response.data.nbrl_access_token)
          commit('Global/SET_TOKEN', response.data.nbrl_access_token, { root: true })
          // dispatch('User2/getUserProfile', response.data.nbrl_access_token, { root: true })
          resolve(response)
        }
      }).catch(error => {
        console.log('unable to authenticate user', error)
        this.$router.push({ name: 'index' })
        reject(error)
      })
    })
  }
}

everytime i tried logging in twitter I got this error

Argument 1 passed to League\OAuth1\Client\Server\Server::getTokenCredentials() must be an instance of League\OAuth1\Client\Credentials\TemporaryCredentials, null given