Mahaveer

Mahaveer

Member Since 2 Years Ago

Jaipur

Experience Points
5,850
Total
Experience

4,150 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
24
Lessons
Completed
Best Reply Awards
3
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 2
5,850 XP
Feb
24
1 month ago
Activity icon

Replied to Get User ID By Access Token ?

@thoasty How to get user ID from header bear access token in passport;

Authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIyIiwianRpIjoiZDYxODY4YWQ1YzEyZWY3YjFkMjE0NjBmNWU4N2ZiNTVlYzlkYjI3MWFkMWVjYzgzOTcwNTg3MTA4MTExZTJmMGE1MDQxNmY0NzkwYTIyMzgiLCJpYXQiOjE1ODI1NDYzMzAsIm5iZiI6MTU4MjU0NjMzMCwiZXhwIjoxNjE0MTY4NzMwLCJzdWIiOiI3Iiwic2NvcGVzIjpbXX0.kTxBqUczYyrNoV0OLrQQoODLtLJ6Zm9xtZxPfvdROznZ1Mo10WA4xrW9t0mhzL6jxc1HMdIngqjo4YIf7m4FaKeJnpW9qt2JMuI_uIgKnrYQe7z__d35mph0B3ykHKhsdjlyKm6iql4LniSuQwNDT2QXmNBVn8MYZ_lA-ioZH4qYQoAQbn-AY7UXwmS6t6Agn3gePJgajjRmIxCYLuseHSbRDt_2X9DUwLrSm6sFKKCqsJQyZPto0Hmxgv_a4A-NHIJ6ZXEE3ql8Bx6PkebK2aKX97l1SVYx4NjwFvQn8PsvZRm1HU05gnwzSPALfBhcWoF7rr6u8RuZwdLGwOUnfgOz1P0EzsJt1qgnCg0hAJ1MkZT4Lkcr_2MxPYVhW2bJXZqf89jHf9NBLjOv0j8q_rvVhKmG5DazeVF-SBHBURIDJZtUX75dve_LBYawPox0KcsYKmU6e55epjL1WXwaZhxF7O81nb3Shu7TJx6kSNK5Nm65MuEnLFRH81eLocLpInPD26Z7noPxuEgWnN4hNl9b6N_QneYTE73t0g07NP3Fg-ckFsZcWlkVJe8uslwr3nlv30UBj9TTdXjtZB80MoPjuP23Ys8QdbwGfNJBb9bLn1kB1_N14p06IWIc8Kvq0I2llq_1jmmJpksWbYreXlyxEemDHDaL6GKd9cxjfPc

Activity icon

Started a new Conversation Get User ID By Access Token ?

Without using auth middleware, how to get user id by token?

//Get access token
        $access_token = $request->header('Authorization');

        // break up the string to get just the token
        $auth_header = explode(' ', $access_token);
        
        $token = $auth_header[1];
        
        // break up the token into its three parts
        $token_parts = explode('.', $token);
        
        $token_header = $token_parts[0];

        // base64 decode to get a json string
        $token_header_json = base64_decode($token_header);
        
        // then convert the json to an array
        $token_header_array = json_decode($token_header_json, true);
        
        $user_token = $token_header_array['jti'];
        
        // find the user ID from the oauth access token table
        // based on the token we just got
        $user_id = DB::table('oauth_access_tokens')->where('id', $user_token)->first();

        

        // then retrieve the user from it's primary key
        $user = User::find($user_id->id);

        echo $user->id ?? '';
        exit();

Feb
13
1 month ago
Activity icon

Started a new Conversation Passport Token Expiry Check.

How can i check if access token is expired.

if token expired. how to get error message like this.

{
    "message": "Token expired."
}

Feb
11
1 month ago
Activity icon

Replied to Laravel Passport Unauthorized Postman

@bobbybouwmann sir, Yes sir i'm sending acces token in postman header. but not working. api give response

{
    "status": false,
    "message": "Unauthorized"
}

After set default auth api. it working fine. but froent end user auth not working.

My auth file

return [

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'passport',
            'provider' => 'users',
            'hash' => false,
        ],
    ],

];
Feb
10
1 month ago
Activity icon

Started a new Conversation Laravel Passport Unauthorized Postman

Passport Token not working.

User login controller method

public function userlogin(Request $request)
    {
       $validator = Validator::make($request->only(['email', 'password']), [ 
            'email' => 'required|string|email',
            'password' => 'required|string'
        ]);

       if ($validator->fails()) { 
            $response = [
                'status' => false,
                'message' => $validator->errors()->first(),
            ];
            return response()->json($response, 401);            
        }

        $credentials = request(['email', 'password']);

        if(!Auth::attempt($credentials))
        {
            $response = [
                'status' => false,
                'message' => trans('auth.failed'),
            ];

            return response()->json($response);
        }

        $user = $request->user();

        $objToken = $user->createToken('quechua');

        $strToken = $objToken->accessToken;

        $expiration = $objToken->token->expires_at->toDateTimeString();

        $response = [
            'status' => true,
            'message' => 'Login successfully.',
            'access_token' => $strToken,
            'token_type' => 'Bearer',
            'expires_at' => $expiration,
            'data' => [
                'first_name' => $user->first_name,
                'last_name' => $user->last_name,
                'email' => $user->email,
            ]
        ];

        return response()->json($response);
    }

Get user detail controller method

public function details() 
    { 
        //Check user login or not
        if (Auth::check()) {

            //Get Login user detail
            $user = Auth::user();
            
            $userarray = [
                'user_id' => $user->id,
                'first_name' => $user->first_name ?? '',
                'last_name' => $user->last_name ?? '',
                'email' => $user->email ?? '',
                'job_title' => $user->usermeta->job_title ?? '',
                'about_me' => $user->usermeta->about_me ?? '',
            ];

            $response = [
                'status' => true,
                'message' => 'User profile detail',
                'data' => $userarray,
            ];

            return response()->json($response, 200);

        }else{

            $response = [
                'status' => false,
                'message' => 'Unauthorized',
            ];
            
            return response()->json($response, 401);
                
        }

        exit();
    }
Jan
12
2 months ago
Activity icon

Started a new Conversation Payumoney Payment Gateway Issue.

Redirection issue after add card detail. Getting this url http://180.179.174.15:3000/pgSimulator/axis/redirect

This is Payumoney Code

/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function payment(UserwalletRequest $request)
    {
        $getuserDetail = User::find($this->getuserId());
        if(!$getuserDetail){
            return redirect(route('my_wallet'))->with('error', 'oops something went wrong. please try again later.');
            exit;
        }
        $wallet_amount = request('wallet_amount');
        $attributes = [
            'txnid' => strtoupper(str_random(8)), # Transaction ID.
            'amount' => number_format($wallet_amount, 2), # Amount to be charged.
            'productinfo' => "Subscription",
            'firstname' => $getuserDetail->name, # Payee Name.
            'email' => $getuserDetail->email, # Payee Email Address.
            'phone' => $getuserDetail->mobile_no, # Payee Phone Number.
        ];
        
        return Payment::make($attributes, function ($then) {
            $then->redirectTo('payment/status', 'SSL');
        });
    
    }
    
    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function status(Request $request)
    {
        try {
            
            $payment = Payment::capture();
            // Get the payment status.
            //$payment->isCaptured() # Returns boolean - true / false
            if($payment->isCaptured()==false){
                return redirect(route('my_wallet'))->with('error', 'Payumoney transaction canceled by you.');
                exit();
            }
            $payu_payment_id = $payment->id; //Get payumoney payment id
            $wallet_amount = $payment->amount; //Get amount
            $transaction_id = $payment->txnid; //Get payment txnid
            $payment_status = $payment->status; //Get payment status
            $unmapped_status = $payment->unmappedstatus; //Get payment unmapped status
            $payment_mode = $payment->mode; //Get payment mode
            $bankref_num = $payment->bank_ref_num; //Get bank ref num
            //$bank_code = $payment->bankcode; //Get bank code
            $card_num = $payment->cardnum; //Get card num
            $name_on_card = $payment->name_on_card; //Get name on card
            $issuing_bank = $payment->issuing_bank; //Get issuing bank
            $card_type = $payment->card_type; //Get card type           
            
            $create = '';
            $update = '';
            $user_id = $this->getuserId();
            
            $user_wallet_detail = Userwallet::where('user_id', $user_id)->first();
            if($user_wallet_detail){
                
                $new_remaining_amt = $wallet_amount+$user_wallet_detail->remaining_amt;
                $new_total_amt = $wallet_amount+$user_wallet_detail->total_amt;
                $update = Userwallet::find($user_wallet_detail->id);
                $update->remaining_amt = $new_remaining_amt;
                $update->total_amt = $new_total_amt;
                $update->update();
                $userwallet_id =   $user_wallet_detail->id;
                
            }else{
                
                $create = Userwallet::create([
                    'user_id' =>   $user_id,
                    'remaining_amt' =>   $wallet_amount,
                    'total_amt' =>   $wallet_amount,
                ]); 

                $userwallet_id =   $create->id;
            }        

            if($create || $update){
                $paymenthistory = Walletpaymenthistory::create([
                    'userwallet_id' =>   $userwallet_id,
                    'user_id' =>   $user_id,
                    'payu_payment_id' =>   $payu_payment_id,
                    'transaction_id' =>   $transaction_id,
                    'card_number' =>   $card_num,
                    'amount' =>   $wallet_amount,
                ]);
        
                return redirect(route('my_wallet'))->with('success', 'Wallet amount updated successfully.');
            
            }else{
                return redirect(route('my_wallet'))->with('error', 'Oops. Something went wrong. Please try again.');    
            }
            
        } catch (\Exception $e) {
            
           return redirect(route('my_wallet'))->with('error', 'Oops. Something went wrong. Please try again. '. $e);
           
        }
        
    }
Dec
30
3 months ago
Activity icon

Replied to How To Manage Dynamically Data Using Loop?

@snapey sir, Html

#user model
public function userimages()
{
    return $this->hasMany('App\Models\Userimage', 'user_id');
}
#html section
<div class="col-md-4">
    @foreach($user->userimages as $userimage)
    <div class="col-md-8 row">
        <div class="col-md-12">
            <div class="card-avatar main-img select-img">
                <a href="javascript:void()" class="edit-pen new_edoi" id="del_user_img_1" onclick="changePictureFunc('user_img_1');"><i class="material-icons">close</i></a>
                <div class="input file">
                    <input type="file" name="user_images[]" accept="image/*" onchange="eventreadURL(this,'user_img_1');" id="user-images-1">
                </div>
                <input type="hidden" name="images_id[]" value="1">
                <img src="http://localhost/sweety/application/public/uploads/users/15774264423222.jpg" class="img" id="user_img_1" alt="">

            </div>
        </div>

        <div class="col-md-6">
            <div class="card-avatar smallmain-img select-img">
                <a href="javascript:void()" class="edit-pen new_edoi" id="del_user_img_2" onclick="changePictureFunc('user_img_2');"><i class="material-icons">close</i></a>
                <div class="input file">
                    <input type="file" name="user_images[]" accept="image/*" onchange="eventreadURL(this,'user_img_2');" id="user-images-2">
                </div>
                <input type="hidden" name="images_id[]" value="3">
                <img src="http://localhost/sweety/application/public/uploads/users/15774265786624.jpg" class="img" id="user_img_2" alt="">
            </div>
        </div>

        <div class="col-md-6">
            <div class="card-avatar smallmain-img select-img">
                <a href="javascript:void()" class="edit-pen new_edoi" id="del_user_img_3" onclick="changePictureFunc('user_img_3');"><i class="material-icons">close</i></a>
                <div class="input file">
                    <input type="file" name="user_images[]" accept="image/*" onchange="eventreadURL(this,'user_img_3');" id="user-images-3">
                </div>
                <input type="hidden" name="images_id[]" value="5">
                <img src="http://localhost/sweety/application/public/uploads/users/15773579745080.jpg" class="img" id="user_img_3" alt="">
            </div>
        </div>

    </div>

    <div class="col-md-4 row">
        <div class="col-md-12">
            <div class="card-avatar smallmain-img select-img">
                <a href="javascript:void()" class="edit-pen new_edoi" id="del_user_img_4" onclick="changePictureFunc('user_img_4');"><i class="material-icons">close</i></a>
                <div class="input file">
                    <input type="file" name="user_images[]" accept="image/*" onchange="eventreadURL(this,'user_img_4');" id="user-images-4">
                </div>
                <input type="hidden" name="images_id[]" value="6">
                <img src="http://localhost/sweety/application/public/uploads/users/15774269212214.jpg" class="img" id="user_img_4" alt="">
            </div>
        </div>
        <div class="col-md-12">
            <div class="card-avatar smallmain-img select-img">
                <a href="javascript:void()" class="edit-pen new_edoi" id="del_user_img_5" onclick="changePictureFunc('user_img_5');"><i class="material-icons">close</i></a>
                <div class="input file">
                    <input type="file" name="user_images[]" accept="image/*" onchange="eventreadURL(this,'user_img_5');" id="user-images-5">
                </div>
                <input type="hidden" name="images_id[]" value="7">
                <img src="http://localhost/sweety/application/public/uploads/users/15773510226409.png" class="img" id="user_img_5" alt="">
            </div>
        </div>
        <div class="col-md-12">
            <div class="card-avatar smallmain-img select-img">
                <a href="javascript:void()" class="edit-pen new_edoi" id="del_user_img_6" onclick="changePictureFunc('user_img_6');"><i class="material-icons">close</i></a>
                <div class="input file">
                    <input type="file" name="user_images[]" accept="image/*" onchange="eventreadURL(this,'user_img_6');" id="user-images-6">
                </div>
                <input type="hidden" name="images_id[]" value="8">
                <img src="http://localhost/sweety/application/public/uploads/users/15773505726898.png" class="img" id="user_img_6" alt="">
            </div>
        </div>

    </div>
    @endforeach
</div>

How to dynamic this html . https://prnt.sc/qfz3la.

Dec
29
3 months ago
Activity icon

Replied to How To Manage Dynamically Data Using Loop?

@sergiu17 sir How to dynamic this html section https://prnt.sc/qfz3la.

Dec
26
3 months ago
Activity icon

Started a new Conversation How To Manage Dynamically Data Using Loop?

Manage data dynamically using foreach loop.

#screenshot

https://prnt.sc/qfz3la

Thanks