kumar92varun

kumar92varun

Member Since 1 Year Ago

Experience Points 190
Experience Level 1

4,810 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 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

19 Aug
10 months ago

kumar92varun left a reply on CORS Access-Control-Allow-Origin Headers Not Being Added In Api Subdomain

@haizone Initially I was using core PHP to convert the data as JSON response and then echo it:

    $api_response = json_encode($return_data);
    echo $api_response;

I was not using Laravel's inbuilt functionality to return API responses as JSON. As I started using Laravel's JSON Responses method, my API responses started to add all the headers I was expecting to be added:

    return response()->json($return_data);
14 Dec
1 year ago

kumar92varun left a reply on Laravel Session Helper Always Returning Null For First Time On Page

I fixed the problem by commenting the "Encrypt Cookies" middleware in /app/Http/Kernel.php:-

// \App\Http\Middleware\EncryptCookies::class,

After commenting the

protected $middlewareGroups = [
    'web' => [
        //\App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
         \Illuminate\Session\Middleware\AuthenticateSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
    ],

    'api' => [
        'throttle:60,1',
        'bindings',
    ],
];

Thanks all for your answers!

13 Dec
1 year ago

kumar92varun left a reply on Laravel Session Helper Always Returning Null For First Time On Page

Hey Kishore, Thanks for your answer.

The first line:-

$session = session('paramount', []);

Is trying to get the value of session key "paramount", and the second argument [] is the default value supplied if the session key "paramount" doesn't exists. []

Anyways I removed the second argument, the first var_dump output changed to NULL instead of array(0) {}

Every time on a page hit the session global helper returning NULL for the key "paramount".

kumar92varun started a new conversation Laravel Session Helper Always Returning Null For First Time On Page

I am using Session via File driver in Laravel 5.5. The issue is that on every page request I check if session key "paramount" is set or not (for first time visit by the visitor). If not, I am setting the session and if it exists, it should not do anything. Here is the code for the same:-

$session = session('paramount', []);
var_dump($session);
if(empty($session))
{
    initSession();
}
var_dump($session);


function initSession()
{
    session(['paramount.user' => [
        'loggedIn' => 0,
        'id' => null,
        'fullName' => null,
        'firstName' => null
    ]]);

    session(['paramount.cart' => [
        'products' => [],
        'summary' => [
            'noOfProducts' => 0,
            'productTotal' => 0
        ]
    ]]);
}

The output of the above code is:-

    array(0) { }
    array(2) { ["user"]=> array(4) { ["loggedIn"]=> int(0) ["id"]=> NULL ["fullName"]=> NULL ["firstName"]=> NULL } ["cart"]=> array(2) { ["products"]=> array(0) { } ["summary"]=> array(2) { ["noOfProducts"]=> int(0) ["productTotal"]=> int(0) } } }

This output means that for the first visit (when session wasn't setup) the var_dump shows empty array, and after setting the session for key "paramount", it shows dump as expected.

When I refresh the page, I should expect that the session has been setup and the first time var_dump should show result as:-

array(2) { ["user"]=> array(4) { ["loggedIn"]=> int(0) ["id"]=> NULL ["fullName"]=> NULL ["firstName"]=> NULL } ["cart"]=> array(2) { ["products"]=> array(0) { } ["summary"]=> array(2) { ["noOfProducts"]=> int(0) ["productTotal"]=> int(0) } } }
array(2) { ["user"]=> array(4) { ["loggedIn"]=> int(0) ["id"]=> NULL ["fullName"]=> NULL ["firstName"]=> NULL } ["cart"]=> array(2) { ["products"]=> array(0) { } ["summary"]=> array(2) { ["noOfProducts"]=> int(0) ["productTotal"]=> int(0) } } }

But on every page refresh the first time var_dump of session key "paramount" shows an empty array.

array(0) {}

And second dump as expected:-

array(2) { ["user"]=> array(4) { ["loggedIn"]=> int(0) ["id"]=> NULL ["fullName"]=> NULL ["firstName"]=> NULL } ["cart"]=> array(2) { ["products"]=> array(0) { } ["summary"]=> array(2) { ["noOfProducts"]=> int(0) ["productTotal"]=> int(0) } } }

Don't know why this is happening, can someone help?

05 Nov
1 year ago

kumar92varun left a reply on CORS Access-Control-Allow-Origin Headers Not Being Added In Api Subdomain

I updated the question. Now the question is complete.

kumar92varun left a reply on CORS Access-Control-Allow-Origin Headers Not Being Added In Api Subdomain

Here is the full question below. Somehow my code block got trimmed in the discussion body. Pasting my full question below:- I am creating a multi-sub-domain web application using Laravel 5.5 with 3 sub-domains right now:- store.example.com admin.example.com api.example.com

Since store.example.com and admin.example.com need to interact with api.example.com for all the back-end operations via jQuery AJAX, I need to add a "Access-Control-Allow-Origin" header on all requests of api.example.com

I created a middleware in /app/Http/Middleware/CORS.php with the following content:-

kumar92varun started a new conversation CORS Access-Control-Allow-Origin Headers Not Being Added In Api Subdomain

I am creating a multi-sub-domain web application using Laravel 5.5 with 3 sub-domains right now:- store.example.com admin.example.com api.example.com

Since store.example.com and admin.example.com need to interact with api.example.com for all the back-end operations via jQuery AJAX, I need to add a "Access-Control-Allow-Origin" header on all requests of api.example.com

I created a middleware in /app/Http/Middleware/CORS.php with the following content:-

kumar92varun started a new conversation CORS Access-Control-Allow-Origin Not Added In Api Subdomain

I am creating a multi-sub-domain web application using Laravel 5.5 with 3 sub-domains right now:- store.example.com admin.example.com api.example.com

Since store.example.com and admin.example.com need to interact with api.example.com for all the back-end operations via jQuery AJAX, I need to add a "Access-Control-Allow-Origin" header on all requests of api.example.com

I created a middleware in /app/Http/Middleware/CORS.php with the following content:-