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

niloy

niloy

Member Since 2 Years Ago

Dhaka

Experience Points
19,400
Total
Experience

600 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
190
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 4
19,400 XP
Nov
16
1 week ago
Activity icon

Awarded Best Reply on How To Get Auth User From Oauth Token?

Actually it is easy to get user cause I have username in $request. So I don't need to get user from token.

$user = User::where('email', $request->username)->first();

if ($user->hasRole('admin'))
	return $token;
}
Activity icon

Replied to How To Get Auth User From Oauth Token?

Actually it is easy to get user cause I have username in $request. So I don't need to get user from token.

$user = User::where('email', $request->username)->first();

if ($user->hasRole('admin'))
	return $token;
}
Activity icon

Replied to How To Get Auth User From Oauth Token?

@nakov Thanks for your time.

Yes, I have tried but it returns nothing.

I want to check user role before returning token.

Activity icon

Started a new Conversation How To Get Auth User From Oauth Token?

Hi, I'm using laravel passport for api authentication. This code return a token which I can use.

$response = $http->post(config('services.passport.login_endpoint'), [
                'form_params' => [
                    'grant_type' => 'password',
                    'client_id' => config('services.passport.client_id'),
                    'client_secret' => config('services.passport.client_secret'),
                    'username' => $request->username,
                    'password' => $request->password,
                ]
            ]);
            
	$token =  $response->getBody();

	return $token;

But I want to get the user before return the token like $token->auth()->user()

How I can get the user from token?

Thank you.

Oct
20
1 month ago
Activity icon

Started a new Conversation Dependency Installation Failed

I' getting this error while deploying API to heroku.

remote:        Generating optimized autoload files
remote:        > Illuminate\Foundation\ComposerScripts::postAutoloadDump
remote:        > @php artisan package:discover --ansi
remote:        
remote:        In CryptKey.php line 52:
remote:                                                                                       
remote:          Key path "file:///tmp/build_a8bd6864/storage/oauth-private.key" does not ex  
remote:          ist or is not readable                                                       
remote:                                                                                       
remote:        
remote:        Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
remote:  !     WARNING: A post-autoload-dump script terminated with an error
remote: 
remote:  !     ERROR: Dependency installation failed!
remote:  !     
remote:  !     The 'composer install' process failed with an error. The cause
remote:  !     may be the download or installation of packages, or a pre- or
remote:  !     post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
remote:  !     in your 'composer.json'.
remote:  !     
remote:  !     Typical error cases are out-of-date or missing parts of code,
remote:  !     timeouts when making external connections, or memory limits.
remote:  !     
remote:  !     Check the above error output closely to determine the cause of
remote:  !     the problem, ensure the code you're pushing is functioning
remote:  !     properly, and that all local changes are committed correctly.
remote:  !     
remote:  !     For more information on builds for PHP on Heroku, refer to
remote:  !     https://devcenter.heroku.com/articles/php-support
remote:  !     
remote:  !     REMINDER: the following warnings were emitted during the build;
remote:  !     check the details above, as they may be related to this error:
remote:  !     - A post-autoload-dump script terminated with an error
remote: 
remote:  !     Push rejected, failed to compile PHP app.
remote: 
remote:  !     Push failed
remote: !
remote:  ! ## Warning - The same version of this code has already been built: 2084aa011f3c0e5b395af053a556d46d7d1e3a1f
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 2084aa011f3c0e5b395af053a556d46d7d1e3a1f
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy...
remote: 
remote: !	Push rejected to minute-man-api.
remote: 
To https://git.heroku.com/minute-man-api.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/minute-man-api.git'

Thanks for your time.

Oct
16
1 month ago
Activity icon

Started a new Conversation How To Login With OTP, In Laravel Passport OAuth2 Authentication

I'm using Laravel Passport for login authentication. And its working perfectly with username and password authentication. I want to authenticate with OTP based login, but I didn't find any suitable documentation for this. Any idea how to do this?

Thanks for your time.

Oct
15
1 month ago
Activity icon

Awarded Best Reply on How To Set Variable Itself As Variable Value In Laravel

I have fixed this.

I have to modify my code like this.

$json_smsdata = [];
foreach ($users as $user) {
    
    $name    = $user->name;
    $phone   = $user->phone_number;
    $message = rawurlencode("Hi $name, Thanks for using our app!
                            Regards, Niloy
                           ");
    $json_smsdata[]= ['to'=>$phone,'message'=>$message];
}

$smsdata = json_encode($json_smsdata);

Thank you!

Activity icon

Replied to How To Set Variable Itself As Variable Value In Laravel

I have fixed this.

I have to modify my code like this.

$json_smsdata = [];
foreach ($users as $user) {
    
    $name    = $user->name;
    $phone   = $user->phone_number;
    $message = rawurlencode("Hi $name, Thanks for using our app!
                            Regards, Niloy
                           ");
    $json_smsdata[]= ['to'=>$phone,'message'=>$message];
}

$smsdata = json_encode($json_smsdata);

Thank you!

Activity icon

Replied to How To Set Variable Itself As Variable Value In Laravel

Thanks for your response.

I'm getting the same error.

I want to send sms to all users from controller.

Here is the full code in controller.

public function sendSMS(Request $request)
    {
        $users = User::all();

        foreach ($users as $user) {
            
            $name = $user->name;

            $phone = $user->phone_number;

            $message = rawurlencode("Hi $name, Thanks for using our app!
                                    Regards, Niloy
                                   ");
            $genjsons = '{"to":"' . $phone . '","message":"' . $message . '"}';

            $jsonsmsdata = "$genjsons, $jsonsmsdata";
            $jsonsmsdata = rtrim($jsonsmsdata, ',');
        }

        $smsdata = '[' . $genjsons . ']';

//        echo $smsdata;

         $token = 'asedfasdfasdf';
         $smsdata = $smsdata;

         $url = 'http://api.greenweb.com.bd/api2.php';

         $data = [
             'smsdata' => "$smsdata",
             'token' => "$token"
         ];

         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_ENCODING, '');
         curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $smsresult = curl_exec($ch);

//        Result
         echo $smsresult;

//        Error Display
         echo curl_error($ch);

         return redirect('/');
    }
Activity icon

Started a new Conversation How To Set Variable Itself As Variable Value In Laravel

How assign a variable value like this in laravel?

$gen_jsons = '{"to":"' . $phone . '","message":"' . $message . '"},';
$json_smsdata = "$gen_jsons, $json_smsdata";

This code is working in php but I'm getting error in laravel. Error: Undefined variable: json_smsdat

Thanks for your time.