greevesh

greevesh

Web Developer (Laravel) at Freelancer

Member Since 10 Months Ago

Experience Points
16,080
Total
Experience

3,920 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
130
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
16,080 XP
Apr
17
3 months ago
Activity icon

Commented on Wrap Primitives (Sometimes)

Can someone explain the logic of 'return new static' to me? I'm a little confused about this.

Apr
02
4 months ago
Activity icon

Started a new Conversation Stripe\Exception\InvalidRequestException: No Such Plan:

I'm trying to create a subscription with Laravel Cashier and Stripe. My post request that subscribes a user is successfully being passed onto the Stripe back-end. I know this because I've checked the Stripe logs and the requests have statuses 200.

Wonderful.

Despite Stripes approval, Laravel is actually throwing an exception whenever I submit the subscribe form: Stripe\Exception\InvalidRequestException: No such plan: yearly_plan.

yearly_plan is the ID I've given one of my subscription plans that the user gives and the Stripe API retrieves.

The ID's I've given for each of the two plans are correct. I've checked multiple times.

// subscribe.blade.php

        <select class="form-control" name="plan" id="plans">
            <option selected value="">Choose a plan</option>
            @foreach($plans as $planId => $planName)
                <option value="{{ $planId }}">{{ $planName }}</option>
            @endforeach
        </select>
// SubscribeController.php
public function storePaymentMethod()
    {
        $user = Auth::user();

        // if user is logged in
        if (!$user)
        {
            return redirect('login');
        }

        $plans = [
            'plan_H1SbSi9r1YhXNG' => 'Monthly',
            'yearly_plan' => 'Yearly'
        ];

        return view('subscribe', [
            'intent' => $user->createSetupIntent(),
            'plans' => $plans
        ]);
    }

    public function subscribe(Request $request)
    {
        $user = Auth::user();
        $paymentMethod = $request->paymentMethod;
        $plan = $request->planId;

        if (!$user->subscribed())
        {
            // 'create' method will automatically store customers payment method
            $user->newSubscription('subscription', $request->plan)->create($paymentMethod); 
        }

        redirect()
        ->route('confirmation')
        ->with('subscriptionSuccessMessage', 'You have successfully subscribed. See you around!');
}

Mar
21
4 months ago
Activity icon

Commented on Liskov Substitution

This is something I would like to know too.

Feb
24
5 months ago
Activity icon

Replied to Running Valet (any Command) Returns: Target Class [log] Does Not Exist. In Container.php Line 803: Class Log Does Not Exist

I've tried this in projects that have been edited and projects with only a fresh install of Laravel. Same result.

Feb
23
5 months ago
Activity icon

Started a new Conversation Running Valet (any Command) Returns: Target Class [log] Does Not Exist. In Container.php Line 803: Class Log Does Not Exist

I have the Linux Valet fork (cpriego/valet-linux) pulled into my composer.json (I've tried it both locally and globally. Whenever I run the command: valet (and any argument) e.g. valet install. I get this error:

In Container.php line 805:
                                      
  Target class [log] does not exist.  
                                      

In Container.php line 803:
                            
  Class log does not exist  
                            

install [--ignore-selinux]

I issued this on GitHub and the maintainer told me that this doesn't seem like an issue with his package. Currently I have laravel/framework and laravel/installer installed globally. He said it was strange that I had laravel/framework installed globally and this could be what's causing the problem. However, I'll try removing both laravel/framework and laravel/installer and I'll still get this error message before installing them locally in ~/.config/composer/vendor/bin$.

Also removing laravel/framework with composer global remove laravel/framework often returns laravel/framework is not required in your composer.json and has not been removed which I find strange. I can remove laravel/installer easily. Though, I can just remove the laravel/framework directory I think.

This is all a bit confusing and I don't know what the issue could be here.

Has anyone else used Valet with Linux here?

Thanks

Feb
22
5 months ago
Activity icon

Commented on Manage Your Databases

Were you trying this on Windows or Linux? pbcopy is a mac command.

Feb
16
5 months ago
Activity icon

Replied to Getting Started With "Valet" [ReflectionException] Class Log Does Not Exist

I still get the same issue even after running composer global remove laravel/laravel

Feb
15
5 months ago
Activity icon

Replied to Calling Env () Function In Production Mode (from Config File)

@mohammed-h

What are you talking about? I thanked everyone above and liked your comment. It seems like you’re answering questions for the main purpose of increasing your virtual Laracasts score. Not for actually helping people or yourself for that matter.

As for the best answer thing. It’s 1am where I live. I just forgot. I’ll look at the forum again tomorrow as there are other good answers. If yours is the best, I’ll pick yours.

Get a grip.

Activity icon

Replied to Calling Env () Function In Production Mode (from Config File)

@snapey I've since added my .env file with all my credentials and I've pulled them into my config. Why is registering a Braintree service provider necessary? I thought config caching would work anyway?

Thanks for your response

Activity icon

Replied to Calling Env () Function In Production Mode (from Config File)

NOOB ALERT

When I deployed my site using Forge I suddenly remember that the .env file doesn't get pushed to GitHub. So the code in services.php was referencing credentials that didn't exist. I've fixed that now and everything is secure again.

Thank you all

Activity icon

Replied to Calling Env () Function In Production Mode (from Config File)

With env(). (The code above). That’s how I was doing it when it wasn’t working.

Activity icon

Started a new Conversation Calling Env () Function In Production Mode (from Config File)

My deployed website contained a services.php file that referenced my Braintree credentials. For example:

'braintree' => [
        'environment' => env('BT_ENVIRONMENT', 'production'),
        'merchantId' => env('BT_MERCHANT_ID'),
        'publicKey' => env('BT_PUBLIC_KEY'),
        'privateKey' => env('BT_PRIVATE_KEY'),
    ],

However, an error in my logs was thrown basically stating that the credentials weren't set. I thought this was strange as the Laravel docs state that you can call the env function as long as it's in a file contained in the config directory.

So, I stopped referencing my Braintree credentials in my service.php with env and just copy and pasted the credentials straight into my services.php.

I'm no longer getting the error but is this supposed to happen? Also, is this actually secure?

Thanks

Feb
13
5 months ago
Activity icon

Replied to Laravel Forge With Digital Ocean: Internal Server Error 500

Thanks. Yep the errors are logged in there.

Activity icon

Started a new Conversation Laravel Forge With Digital Ocean: Internal Server Error 500

When I access one of the pages of my deployed site I get an internal server error. Nothing appears in my Laravel Forge deployment log to suggest something is wrong:

Thu Feb 13 17:46:39 UTC 2020
From github.com:greevesh/single_product_store
 * branch            master     -> FETCH_HEAD
Already up to date.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: barryvdh/laravel-debugbar
Discovered Package: cartalyst/stripe-laravel
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: hardevine/shoppingcart
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: sven/artisan-view
Package manifest generated successfully.
Restarting FPM...
Nothing to migrate.

I've checked all the nginx log files and there were no reported errors there either. I followed this tutorial perfectly as well: https://laracasts.com/series/learn-laravel-forge/episodes/3

Why on earth am I having this problem?

Activity icon

Started a new Conversation Is It Simple Or At Least Possible To Run Vanilla PHP Projects In A Laravel Valet Environment?

The XAAMP local environment is causing my computer to crash whenever I try and run my project in the browser. So, I'm thinking of changing to Laravel Valet.

Since this is a vanilla PHP project I'm working on, can I simply transfer my project into a Valet environment? I ask because I noticed someone else on Laracasts have a real problem setting up plain PHP in Valet. But this was 3 years ago.

Or is Valet only recommended for Laravel projects?

Thanks

Activity icon

Commented on Step 1: Get PHP Installed

Can you run plain old PHP projects with Valet? Or only Laravel projects?

Feb
11
5 months ago
Activity icon

Commented on Notifications Versus Mailables

Which tool is Jeff using to jump to interfaces just by clicking on them? Is there an equivalent for Visual Studio Code?

Feb
05
5 months ago
Activity icon

Replied to ENV Variables Remain The Same After Clearing Cache

No. I'm running it on localhost. I've tested it on a couple of different apps and the same thing happens. When you run config('db.connection') null is returned.

But when you run config('mail.host') your host is returned (in my case smtp.mailtrap.io).

I'm guessing that the value of some keys can't be accessed through tinker for security reasons?

Feb
04
6 months ago
Activity icon

Replied to ENV Variables Remain The Same After Clearing Cache

I'm getting the exact same problem now with Stripe. Config:clear will allow me to change my app.name but not my stripe.key. I'm checking in Tinker with config('stripe.key'). What's going on here??

Activity icon

Started a new Conversation JavaScript In Laravel 6.0 Braintree: InvalidArgumentException Invalid Keys: TokenizationKey

I'm really having trouble knowing what to do next. After rummaging through the Braintree documentation and getting help from the support team I still don't know where to go. I was hoping someone with Braintree knowledge could help me out here.

Here's the error again: JavaScript in Laravel 6.0 Braintree: InvalidArgumentException invalid keys: tokenizationKey

Instead of a client token to pass to the server, I'm using a tokenization key. This is supposed to be simpler because it can be reused and displayed in the script.

Here is the element I'm trying to pass to:

<input name="tokenizationKey" id="tokenizationKey" type="hidden" value="">

And here is the script that's supposed to pass the tokenizationKey:

{{-- BRAINTREE INTEGRATION --}}
<script src="https://js.braintreegateway.com/web/3.57.0/js/client.min.js"></script>
<script src="https://js.braintreegateway.com/web/dropin/1.21.0/js/dropin.min.js"></script>
<script>
    var button = document.querySelector('#submit-payment');
    var tokenizationKey = 'sandbox_csv9z8wd_7x6bffskqkpyhp6g';

    braintree.dropin.create({
        authorization: tokenizationKey, 
        container: '#dropin-container'
    }, function (createErr, instance) {
        button.addEventListener('click', function () {
        instance.requestPaymentMethod(function (requestPaymentMethodErr, payload) {
            // submit payload.nonce to your server
            document.querySelector('#nonce').value = payload.nonce;
            document.getElementById('tokenizationKey').value = tokenizationKey;
            console.log(tokenizationKey); 
        });
        });
    });
</script>
{{-- END BRAINTREE INTEGRATION --}}

When I console.log the tokenizationKey it appears, but for some reason it's being marked as invalid.

Here's the backed that's supposed to receive it:

$gateway = new Braintree\Gateway([
            'environment' => config('services.braintree.environment'),
            'merchantId' => config('services.braintree.merchantId'),
            'publicKey' => config('services.braintree.publicKey'),
            'privateKey' => config('services.braintree.privateKey')
        ]);

        // request()->validate([
        //     'name' => 'required|min:5',
        //     'email' => 'required|min:10',
        //     'address' => 'required|min:10',
        //     'address2',
        //     'country' => 'required',
        //     'postcode' => 'required',
        //     'card-name' => 'required'
        // ]);

        $amount = Cart::total();
        $tokenizationKey = $request->tokenizationKey;

        $result = $gateway->transaction()->sale([
            'amount' => $amount, 
            'tokenizationKey' => $tokenizationKey,         
            'options' => [
                'submitForSettlement' => true
            ]
        ]);

if ($result->success or !is_null($result->transaction)) 
        {
            $transaction = $result->transaction;
            return redirect()->route('confirmation')
            ->with('paymentSuccessMessage', 'Thank you! Your payment has been accepted.
                                             A confirmation email has also been sent.');

            Mail::send(new OrderConfirmed);
            Cart::destroy(); 
        } 

What am I missing?

Thanks in advance