Braunson

Founder at Geekybeaver

Member Since 5 Years Ago

Ontario, Canada

Experience Points
31,925
Total
Experience

3,075 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
121
Lessons
Completed
Best Reply Awards
37
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 7
31,925 XP
Nov
21
3 weeks ago
Activity icon

Replied to Can't Pass Local Variable To Another Method.

The solution is in the error. The method payment_process expects two parameters

  1. Request object
  2. $productPrice

You are only passing the $productPrice a float to it so it's expecting Request object and getting a float.

You have two options

#1. Remove the first parameter Request $request from your payment_process method (assuming you are not using it) and that will solve your problem. Your payment_process method should look like this now..

public function payment_process($productPrice) {
       
        \Stripe\Stripe::setApiKey('...');
        try {
            Charge::create ( array (
                    "amount" => $productPrice * 100,
// etc ....

#2. Pass the $request object like so in your payment method.

$this->payment_process($request, $productPrice);
``
Nov
13
4 weeks ago
Activity icon

Awarded Best Reply on How To Convert Axios Response To DataURI?

Check this issue thread on axios/axios out, it has multiple solutions https://github.com/axios/axios/issues/513 :)

Nov
11
1 month ago
Activity icon

Awarded Best Reply on Team Create On Registration But Not On Team Invite.

By default only 'owners' can invite people. So allow the registration of a company assuming it's the 'owner' registering every time.

You'll want to add the following to your booted method of your SparkServiceProvider:

Spark::noAdditionalTeams();

See https://spark.laravel.com/docs/9.0/teams at the bottom of Introduction

Nov
09
1 month ago
Activity icon

Replied to Database Schema For Posts With Hashtags And Mentioned Users

Depends how you want to use them and if you want to run reports on usage, etc.. but yes your on the right track..

table: posts

  • id
  • name
  • etc

table: hashtags

  • id
  • name

table: post_hashtags (pivot)

  • post_id
  • hashtag_id
Nov
08
1 month ago
Activity icon

Replied to Autocomplete = "off" Not Working

This seems to be a never ending fight with Google to respect the autofill/autocomplete. There are hackable solutions that may work, but I haven't had a ton of luck.

Check a look at this example thread with some possible solutions https://stackoverflow.com/questions/12374442/chrome-ignores-autocomplete-off

Nov
06
1 month ago
Activity icon

Replied to Spark: How To Allow Users To Not Belong To Any Teams?

It's in the VerifyUserHasTeam middleware. See https://github.com/laravel/spark-aurelius/blob/9.0/src/Http/Middleware/VerifyUserHasTeam.php

If Spark::usesTeams and the user doesn't have any teams, it'll redirect the user to /missing. You can try overriding or creating your own middleware that get's used in this instance.

It's being used in the install stubs that get copied to app/Http/Kernel.php .. see https://github.com/laravel/spark-aurelius/blob/2b4a4225c2045c27597c807f3e786803bed7b53a/install-stubs/app/Http/Kernel.php

Activity icon

Replied to How To Convert Axios Response To DataURI?

Check this issue thread on axios/axios out, it has multiple solutions https://github.com/axios/axios/issues/513 :)

Activity icon

Replied to Team Create On Registration But Not On Team Invite.

By default only 'owners' can invite people. So allow the registration of a company assuming it's the 'owner' registering every time.

You'll want to add the following to your booted method of your SparkServiceProvider:

Spark::noAdditionalTeams();

See https://spark.laravel.com/docs/9.0/teams at the bottom of Introduction

Activity icon

Replied to Advice On Updating Database Entries Via Jobs

This is what chained jobs are for. https://laravel.com/docs/5.8/queues#job-chaining check them out!

I think you are on the right path and they are doing exactly what they should be.

Oct
31
1 month ago
Activity icon

Awarded Best Reply on Save Stream File To Filesystem

Looks like you have permission issues on accessing files on AWS. Check your AWS file permissions for your bucket/upload user and that should resolve the issue.

Also try this when storing the file.. to make the permission public.

Storage::put(
    $request->recording_uuid.'.mp3',
    Nexmo::get($request->recording_url)->getBody(),
    'public' // See this 
);

Also if that doesn't work, check this thread for some ideas https://laracasts.com/discuss/channels/laravel/laravel-52-amazon-s3-viewing-uploaded-file-accessdenied

Oct
30
1 month ago
Activity icon

Replied to Spark - Multiple Developers Working On Spark Project

You need to generate a Git token from the account that has access to the Spark repo, then add that into the composer file so it's used to retrieve the private package. It'll be added to your projects composer.json looking like so..

{
    "config": {
        "github-oauth": {
            "github.com": "your-generated-token-here"
        }
    },
}
Activity icon

Replied to Save Stream File To Filesystem

Looks like you have permission issues on accessing files on AWS. Check your AWS file permissions for your bucket/upload user and that should resolve the issue.

Also try this when storing the file.. to make the permission public.

Storage::put(
    $request->recording_uuid.'.mp3',
    Nexmo::get($request->recording_url)->getBody(),
    'public' // See this 
);

Also if that doesn't work, check this thread for some ideas https://laracasts.com/discuss/channels/laravel/laravel-52-amazon-s3-viewing-uploaded-file-accessdenied

Oct
17
1 month ago
Activity icon

Replied to Help With Getting FileSystem Working?

Your using storage_path() helper in your root. This literally uses /storage + whatever you have inside the ().

What you would want is public_path instead of storage_path. However I don't recommend doing it that way. Instead follow the doc's suggested method.

Upload to the storage path, and then symlink your storage folder to public.

The public disk is intended for files that are going to be publicly accessible. By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public. This convention will keep your publicly accessible files in one directory that can be easily shared across deployments when using zero down-time deployment systems like Envoyer.

Check this out on how to symlink storage to public and how to use the asset() helper https://laravel.com/docs/5.8/filesystem#the-public-disk

Activity icon

Replied to LazyController Still Running Out Of Memory?

Try batching the insert statement.

Oct
15
1 month ago
Activity icon

Replied to Problem With Group By First Letter JavaScript

I'd suggest doing this in the collections level of Laravel using something like mapToGroups.

Here's an example

public function chunkByAlpha(Collection $collection)
{
    return $collection->mapToGroups(function($item, $key) {

        return ($this->isAlpha($item->name[0]) ? [strtoupper($item->name[0]) => $item] : ['#' => $item]);
    });
}

public function isAlpha($toCheck)
{
    return preg_match("/^[a-zA-Z]+$/", $toCheck);
}

Taken from https://stackoverflow.com/a/53766995/610880

Activity icon

Replied to What's The Best Timeline Package In VueJs

It really depends on what features or functionality your looking for. What's best for you isn't necessarily what's best for someone else.

That being said, here are some options!

Activity icon

Replied to Displaying Nested Comments ..... 10 Nested Replies At A Time

This really depends on how your database is structured and how things are linked together. Here's an article that explains a nested comment system from start to finish https://appdividend.com/2018/06/20/create-comment-nesting-in-laravel/

Activity icon

Replied to Get Relationship From Array Of Ids

I'm not entirely sure about casting to an array and subsequently a relation however you could loop over the arrays using a Accessor (which is a way to format attributes when you retrieve them from the db) and create your object/array of relations manually.

Activity icon

Replied to Duplicate Keys In Array

Can you remove the Applicant key itself and let it default to a number.. since they are all stored in an Applicants key-named array?

Activity icon

Replied to Multi-website With One System

That's not how you would ideally do it. Also it's frequently references as "multi-tenant" paired.

Here's a good article on it https://medium.com/@weihien90/laravel-5-simple-subdomain-for-multi-tenant-application-551ee489b599

The article gives some examples on how to implement middleware to "CheckTenant" and what to do from there :)

Oct
09
2 months ago
Activity icon

Commented on Integrate A Site Template

Why drag the CSS into the pub directory, instead use the resources/css + Laravel Mix? Feels misleading to new comers..

Oct
07
2 months ago
Activity icon

Replied to Teams Via Subdomain

Something along the lines of this https://medium.com/@weihien90/laravel-5-simple-subdomain-for-multi-tenant-application-551ee489b599

If you do pursue it with Spark, it'll work almost the same way.

Sep
30
2 months ago
Activity icon

Replied to Where Are You All From?

Canada eh :)

Sep
24
2 months ago
Activity icon

Replied to Check Quantity If It Available On Stock

We don't know what your database looks like for the products or how it's structured. But you can do a check in your controller/service to check stock beforehand (before any save logic) and respond accordingly..

Sep
01
3 months ago
Activity icon

Replied to How Would You Set Up "Credit" In Movie Database

I think the pivot table is the best optioin. If you want to have parent and sub credits, then apply that on your pivot table..

person_id | movie_id | role_parent_id | role_child_id
Aug
14
3 months ago
Activity icon

Replied to Are Event Listeners Cached In Some Way?

From the docs..

... during your deployment process, you should run the event:cache Artisan command to cache a manifest of all of your application's events and listeners

So yes event & listeners are cached. Clear your cache on deployment and if you are using queue's, restart them on deploy.

Aug
01
4 months ago
Activity icon

Replied to Saving API Usage For Metered Billing

I don't know of any handy package but I want to suggest using Middleware to do the counting for you, it abstracts that logic away from your API endpoint controller methods.

If you do build one, you should publish it as a package, I'm sure others would appreciate it :)

Activity icon

Replied to How To Setup A Callback API Endpoint That Recieves Payment Status From A Payment Gateway

I'm not sure what Payment Processor you are using but you would look at their dev docs to see what is being sent to your server when you provide them with a webhook. Are they providing a POST or GET request?

They should also provide you with some information as to what they are POSTing. Typically a webhook will be a POST especially when they are sending you a bunch of data.

So check your PP's dev docs to see what they send you and how. Outside of that it's up to you to do with the $request as you choose.

As an example, MailGun will POST to a webhook URL I provide. I used their docs to find out what they POST to me and I actually validate the incoming request (using custom Middleware) well I validate the signature included in the request.

So check the docs, and what you are provided with do what you need to with the $request :)

Jul
30
4 months ago
Activity icon

Replied to Change Request Body Middleware

Your looking at (from the title) a method for Slim maybe?

You can do this with Middleware doing so like this:

Example File: app/Http/Middleware/TestMiddleware.php

<?php namespace App\Http\Middleware;

use Closure;

class TestMiddleware
{

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $input = $request->all();

        if (isset($input['foo'])) {
        $input['foo'] = 'bar';

            // Input modification
            $request->replace($input);

            \Log::info($request->all()); // Shows modified request
        }

        return $next($request);
    }

}
Jul
24
4 months ago
Activity icon

Replied to Convert String Array To Array Of Int(s)

array_map to intval ;-)

$array = ["123", "34", "223"];
$integerIDs = array_map('intval', $array);
Jul
17
4 months ago
Activity icon

Replied to Saving For Each Loop

Try clearning your cache and cookies:

php artisan cache:clear then delete browser cookies. This issue has been posted previously on this form, try searching next time :)

Jul
14
4 months ago
Activity icon

Replied to Laravel Make Service Pattern Command

Just a suggestion, good job but perhaps stub out some example methods in the service stub as a starting point for others? :)

Jun
27
5 months ago
Activity icon

Replied to How Can I Show Edit And Delete Button To The Post Owner In Vuejs Comeponent Larave?

You will need some way to know the current logged in user as well as the post user. Since you are passing in the post parameter to the deletePost method in Vue you should have access to post.user_id now you just need to find a way to get the currently logged in user.

You can set it like so https://stackoverflow.com/a/52703853/610880

Then you would use v-if something like this:

<li><a @click="deletePost(post,key)" v-if="post.user_id === user.id" title="Edit Post" class="pencil-edit">Edit Post</a></li>
Jun
24
5 months ago
Activity icon

Replied to Laravel Cashier - Adding Days To Subscription

@Tyler The repo is your friend in this case, you can see what happens then you 'cancel' a subscription via the cancel method.

For Stripe: https://github.com/laravel/cashier/blob/707ef5ec28974f74c57461ef25c125c46050d885/src/Subscription.php#L404

The code will cancel the subscription at the end of the billing period. The code will set the cancel_at_period_end field in stripe to true. Stripe will end the subscription at the end of the billing period.

For BrainTree: https://github.com/laravel/cashier-braintree/blob/1b9c2500a030fa7589386d829160d63669ead7fa/src/Subscription.php#L369

You can see the code uses the BraintreeSubscription class to call cancel() which if we dig into the braintree/braintree_php package you'll see here it calls the Braintree API Gateway and calls here to cancel the subscription in Braintree.

So to answer your question simply:

  1. Yes there is a difference in using the cancel subscription method vs deleting the entry from the DB. The subscription is technically stored on the Processor side (Stripe/Braintree), your app's database just keeps reference of it, deleting it in your db will just delete your app's reference, the customer will still be billed by the processor (Stripe/Braintree) since that's where the actual processing/charging magic happenbs.

  2. Cashier-Braintree is just a wrapper to help facilitate the use of BrainTree in Laravel, if you want to use t he direct BrainTree PHP library, go for it, but I'd personally use Cashier and if it doesn't do what I need, to just extend it to suit my needs.

I hope this helps give you more insight and a better idea on how things work under the hood with Laravel's Cashier/Cashier-Braintree :)

Activity icon

Replied to Integrate PHP Code With Contact Form 7 Fields

@hassanshahzadaheer You can see how to do it in the CF7 docs https://contactform7.com/selectable-recipient-with-pipes I've updated my answer to include an example of a dropdown in the CF7 edito.

An example of how to create dropdowns in CF7 editor:

[select cows "1" "2" "3"]
Jun
21
5 months ago
Activity icon

Replied to Laravel Cashier - Adding Days To Subscription

Yes that sounds like your best bet. I'm not familiar at all with BrainTree myself but from the flow you've described.

  1. Cancel users existing subscription $user->subscription('fooSub')->cancel();
  2. Create a subscription that ends on X date
  3. Subscribe the user to the new subscription.

On step 2, since Cashier (BrainTree) doesn't seem to have methods to create custom subscriptions, you'll have to do this likely with the BrainTree PHP library @ https://developers.braintreepayments.com/reference/request/subscription/create/php manually. You will want to set the billing day of month to the new date you need.

$result = $gateway->subscription()->create([
  'paymentMethodToken' => $token,
  'planId' => 'custom_plan_foo1234',
  'billingDayOfMonth' => 30,
  // ...
]);

After that you can just re-subscribe your user using Cashier like so: $user->newSubscription('newSub')->create($token); You will need the CC token also to re-subscribe the user.

Activity icon

Replied to 'no Input Specified' Challenge On The Browser When Trying To Load 'homestead.test'

Looks like you have another issue here where the base box won't download. Please check this solution https://github.com/mitchellh/vagrant/issues/6725#issuecomment-223733553

Activity icon

Replied to Laravel Cashier - Adding Days To Subscription

Yes anchorBillingCycleOn is for Stripe only. As for BrainTree it doesn't look like there is an option for what you need in Cashier.

I can suggest another option, is using the 'trial days' instead and requiring CC on setup so they have X many days before they are "subscribed". This however only works on initial sign up but not necessarily when they are/have been subscribed already.

You cannot change the billing date on an existing subscription, you must cancel the subscription and create a new one.

With Braintree, the next billing date is calculated, and so can't be changed unfortunately.

Activity icon

Replied to 'no Input Specified' Challenge On The Browser When Trying To Load 'homestead.test'

Make sure your Homestead.yaml project / folders paths are correct. Then run vagrant up --provision and try the URL again.

Activity icon

Replied to Lavacharts Gauge Colors

I'm not super familiar with Lavacharts but looking at the docs on both Lavacharts and Google it looks like only

  • greenColor
  • redColor
  • yellowColor

https://developers.google.com/chart/interactive/docs/gallery/gauge#Configuration_Options

Activity icon

Replied to Database Sessions Pruning

Yes they are cleaned out. There is another thread on Laracasts here asking the same question. Check out https://github.com/laravel/laravel/blob/master/config/session.php specifically look at the comment for Lottery.


    /*
    |--------------------------------------------------------------------------
    | Session Sweeping Lottery
    |--------------------------------------------------------------------------
    |
    | Some session drivers must manually sweep their storage location to get
    | rid of old sessions from storage. Here are the chances that it will
    | happen on a given request. By default, the odds are 2 out of 100.
    |
    */

Laravel cleans up expired session entries based on a lottery setting.

However note that not all session drivers require manual cleanup, something like Redis doesn't need it because it automatically deletes expired keys.

You can see in the StartSession middleware where it cleans up the sessions using the method collectGarbage which cleanrs the session based on the lottery config (above).

https://github.com/illuminate/session/blob/master/Middleware/StartSession.php

The default configurations are [2, 100]. It means that a random integer is chosen between 1 and 100, if it's lower or equals to 2 the cache will be cleared. (Aka you have a 2% possibility to clear the cache every call).

Jun
20
5 months ago
Activity icon

Replied to Integrate PHP Code With Contact Form 7 Fields

You'll want to look into the Hooks the Contact Form 7 provides. You'll hook into the response to output what you want.

As for the dropdowns, you create them in the Contact Form 7 form editor with the provided options.

You can see a list of hooks at http://hookr.io/plugins/contact-form-7/5.1.3/hooks/#index=a (for the latest version of CF7), you'll probably want something like the wpcf7_ajax_json_echo hook to modify the outbound response returned to the user. Here's an example:

Something like this (untested), but it would go in your wp-content/themes/footheme/functions.php (your theme, functions file).

add_filter('wpcf7_ajax_json_echo', function( $response, $result )
{
    $cow  = 100;
    $goat = 200;

    if (isset($response['cow']) || isset($response['goat'])) {
        if (isset($response['cow'])) {
            $cowSelect = $response['cow'];
            $cow = ($cow - $response['cow']);

            switch ($cowSelect) {
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                    $message .= 'Total '.$cow.' cows remaning'.'<br/>';
                    break;
            }
        }

        if (isset($response['goat'])) {
            $goatSelect = $response['goat'];
            $goat = ($goat - $response['goat']);

            switch ($goatSelect) {
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                    $message .= 'Total '.$goat.' goats remaning'.'<br/>';
                    break;
            }
        }
    }

    return $response;
}, 10, 2);

Then you just need to create a dropdown with the options you want, make the dropdown required (if it needs to be required) in the Contact Form 7 form editor.