Member Since 5 Years Ago

Ontario, Canada

Founder at Geekybeaver

Experience Points 28,255
Experience Level 6

1,745 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 120
Best Reply Awards 32
Best Reply
  • 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


    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement


    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.

25 Apr
1 day ago

Braunson left a reply on How To Sort Posts By Latest Commented

@memele Whoops, here you are

$latestComments = Post::with('comments')->get()->orderByDesc('comments.created_at');

We sort using Collection helpers after getting the results :)

Braunson left a reply on Validation On Required_if

I'm not entirely sure what your trying to do. If you want to (on the Update Form Request) only require the banner field when it's filled out then you would likely use the sometimes validation method.

In some situations, you may wish to run validation checks against a field only if that field is present in the input array. To quickly accomplish this, add the sometimes rule to your rule list:


'banner' => 'sometimes|required|mimes:jpeg,png|dimensions:width=1920,height=1080',

Braunson left a reply on (1/1) FatalErrorException Maximum Execution Time Of 60 Seconds Exceeded

Looks like if the file is large it's taking too long to load it.

In this case I'd suggest offloading this type of large operation to the queue system and queue it.

Alternatively you could batch loop and batch insert the data (instead of one by one) which may speed up the script but again all depends on the file size and contents it has to go through, your best bet is to queue this up.

Braunson left a reply on Logging Raw Data

This is the function of the logger. I don't think there's an easy way to disable timestamps other than to create your own Logger/driver.

Braunson left a reply on How To Sort Posts By Latest Commented

Try something like this..

$latestComments = Post::with('comments')->orderBy('comments.created_at', 'desc)->get();
24 Apr
2 days ago

Braunson left a reply on Achieve Available Venue On That Date.

Hmm you are checking for Venues with bookings between your start and end date.

What about using whereNotBetween

$availableVenue = Venue::with(['bookings' => function ($query) use ($startDate, $endDate) {
    $query->whereNotBetween('startDate', [$startDate, $endDate])
            ->whereNotBetween('endDate', [$startDate, $endDate]);


Braunson left a reply on How To Validate URL Query Parameters?

Look into using Form Requests to validate your inbound form requests before you need to do any logic.

Braunson left a reply on Swift_IoException Unable To Open File For Reading [1]

Sounds like your path to the file is wrong. Does it say which line? Perhaps it's the first one, are you referencing an existing file somewhere in SalesregisterExport?

Have you confirmed permissions are correct (so it can create a file)?

Braunson left a reply on Scheduling Sending Multiple Queued Mails

Can you confirm your server has mail enabled/installed? Try adding this in a php file and running it to test mail.

$sender = '[email protected]'; // Update this
$recipient = '[email protected]'; // Update this

$subject = "php mail test";
$message = "php test message";
$headers = 'From:' . $sender;

if (mail($recipient, $subject, $message, $headers))
    echo "Message accepted";
    echo "Error: Message not accepted";

If that works and you get an email let us know, otherwise it may be you have to enable/fix mail on your local server first before you'll receive anything.

Additionally if mail is enabled and working properly elsewhere, do you have any errors in your log? Have you tried changing your .env file MAIL_DRIVER to log? If it's logging them it's likely a mail related issue.

Braunson left a reply on How Do I Implement An Interface Onto A Laravel Project Properly?

From what I understand, it's not possible to pass the route variable to the Controller's constructor. However there are other methods.. such as getting the Route::current()->parameter('accountType') and then setting it in the constructor but you wouldn't inject the dependency tho necessarily.

For example:

public function __construct(AccountTypeInterface $accountType)
    $accountType = \Route::current()->parameter('accountType');
    $this->accountType = $accountType->where('slug', $accountType)->first();

You may be able to use the request() help also instead of route()/Route:: This is untested but may be a possible solution.. no it's not ideal but it may work.

FWIW: There was a proposal in the Laravel framework repo for this same feature at it was rejected :(

23 Apr
3 days ago

Braunson left a reply on Validation On Required_if

Have you tried using the required_unless rule?

The field under validation must be present and not empty unless the anotherfield field is equal to any value.

'fee' => 'required',
'amount' => 'bail|required_unless:fee,=,2|integer|gte:1',

bail = Stop running validation rules after the first validation failure.

So it'll try and validate required_unless, but if that fails then it'll bail.

Braunson left a reply on Best Way To Tackle This App? Ideas Welcome

Welcome! Ok so there are couple ways you can do this but since it's super simple, you can literally use a flag like you mentioned on the users table.

A user registers and by default is a Client.

You don't necessarily have to have a flag to specify client/admin just admin. This way by default all users are clients. You'd have to manually (at least for the first user) update their to have the is_admin flag set to true/1.

So you'll have 1 users table, with an additional flag called is_admin set to 0 by default. This way you can use the auth/register system that comes with Laravel.

Now for checking if they are an admin or not.. you can create a custom Blade Directive for use in Blade Views (see the Laravel docs about creating directives) and you would add the helper on the User.php model (which you'd also use to check in the blade directive). Let me give you the code..

User.php (the model, place in the class)

 * A helper to determine if the current user is an admin
public function isAdmin()
    return $this->is_admin;

AppServiceProvider.php (put this code inside boot() method

 * If statement check if user is an admin
 * Usage: @admin yep they are an admin @admin
Blade::if('admin', function() {
    return auth()->check() && auth()->user()->isAdmin();

Now you can use the directive in your views like this..

This is text for the admin

And you can use the helper method in the code/middleware on a user like so:

if ($user->isAdmin()) {
    // Do admin stuff

If you wanted, you could create a helper and directive to return bool if they are a client.. like so..

User.php (the model, place in the class)

 * A helper to determine if the current user is a client
public function isClient()
    return ! $this->is_admin;

AppServiceProvider.php (put this code inside boot() method

 * If statement check if user is an admin
 * Usage: @admin yep they are an admin @admin
Blade::if('client', function() {
    return auth()->check() && auth()->user()->isClient();

Hope this helps!

An example middleware for checking if admin is this..



namespace App\Http\Middleware;

use Closure;

class CheckAdmin
     * Handle an incoming request.
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
    public function handle($request, Closure $next)
        // Is there current user an admin
        if ($request->user()->isAdmin()) {
            return $next($request);

        return response('Unauthorized.', 401);

Don't forget to register the middleware in your app\Http\Middleware\Kernel.php file and use it wherever needed

Braunson left a reply on How Can I Get Data From Database?

Hmm not entirely sure what your having issues with as you don't specifically explain. You should be able to access the variable $totalMarks in your blade view and use it?

Braunson left a reply on How Can I Get Chunked Value From Nested Eloquent Collection

I'm not sure how products relate to brands (assuming it's by brand_id) so something like..


Braunson left a reply on What Is Your Laravel Design Pattern?

In existing projects you'll have to plan a way to move things part by part or module by module. It'll be tedious in an existing project, especially when it's a larger project.

A good Laracasts series is if your looking to learn more SOLID principles in PHP.

I'd suggest if you are trying to use SOLID to stick to it as much as possible but no code is perfect and you'll likely not be able to stick to it 100% for every piece of code so don't sweat the small things ;-)

18 Apr
1 week ago

Braunson left a reply on How Do I Get All Users On A Team With A Specific Role?

Something like this.. at least for Spark.. we query the pivot table team_users

    $users = User::whereHas('teams', function($query) {
        $query->where('team_users.role', '=', 'professional');
17 Apr
1 week ago

Braunson left a reply on How To Access DB As A Class Instance?

Sure you can conditionally build a query with the DB facade.

An example:

$results = DB::table('orders')
    ->where('branch_id', Auth::user()->branch_id)
    ->when($request->customer_id, function($query) use ($request){
        return $query->where('customer_id', $request->customer_id);

Checkout this article

10 Apr
2 weeks ago

Braunson left a reply on Using Laravel Cashier How Can I Access User's Subscribed Plan?

While I'm not sure what version of Cashier your using, if you take a look at the repo and check the Billable.php file you'll see a relation to Subscriptions.

So you can check a user's $user->subscriptions()

Additionally you can check a user's subscription status for a specific plan like so:

if ($user->subscribed('default')) {

Braunson started a new conversation Inconsistency Of Post Timeline Data On Profile

I noticed the timeline posts on a user's profile are cached/stored separately to the updated post?


I posted an initial response to someone with a broken link (I mis-formatted it) but edited the post and fixed it. When I go to my profile, I still see the previous post.

Perhaps it's queued and hasn't updated but just an inconsistency of same-data I noticed.

Braunson left a reply on I Need Structural Advices For A Complex Logic To Create A Calendar With Events

You'll want to create "filtering" classes to filter inbound data as well as outbound data (if you need to). I'd suggest checking out the (spatie/laravel-fractal)[] package for doing this.

This will help take input from your third party and filter and format it to something you can use to insert into models, insert into events, etc.

Now you can use Controllers, Events, Queues normally without the bloated logic to process the raw data.

An examaple of incoming raw data flow/path..

API IN -> Raw Data -> Controller -> Fractal -> (back to) Controller -> Create Calendar + Events

Braunson left a reply on Checking If File Is Done

An interesting challenge. There are a few methods to solve this. Once you have a solution below to check agianst if the file is completed or not, if not you can re-queue the job ;-)

  1. Use a signal file tthat is created before the upload and removed when completed.
  2. Get a list of all currently opened files in that dir by parsing the output of UNIX/Linuxlsof` command and check if your file is in that list (tho you may encounter permission issues with this)
  3. Some FTP managers offer a configuration option that for example gives uncompletes files the extension of .part or locks the file system level (similiar to vsftp)
  4. Check if the file's last modification of that file is longer than a specific threshold.

I'm thinking #4 is likely your best bet here.

Additionally another option if you have PECL Inotify extension installed you can make use of inotify_read and check for the event code (IN_CLOSE_WRITE)[]

These above solutions were mainly taken from (this thread)[] on SO and there are a few more options to ponder there.

Braunson left a reply on How To Conditionally Chain Queue Jobs

You can use the normal job chaining..

    new SmpWorkbookExport($data),
    new MergeWorkSheets($data)

Pass an array of data needed for each job so you can do the logic calculation inside each job. If a chained job needs not to run you can do the check inside the job and either $job->delete() or return false to end the job.

If you need to pass data from one chained job to another sequentially, I don't have a solid Laravel answer but Guzzle's Promises may be an option.. check this

Additionally if you need to pass data to another job in the chain, you could use something like redis/cache to temporarily store the data to pass it down the line and at the end delete/empty that cached data (cached data is set in the first queue job, cleared out in the last when it's no longer needed)

Braunson left a reply on Remove Header From Laravel Markdown Template

You will want to check out this in the docs

  1. Publish the components
  2. Edit the templates/components/theme

Then you can edit any aspect of the markdown template you want i.e. /resources/views/text/header.blade.php

Braunson left a reply on Laravel Horizon Critical Issue

Looks like this is an ongoing issue (Even with Laravel 5.8)

Braunson left a reply on How Do You Manage Models Views?

Hey there,

I think this depends on your requirements. You gave the example of increasing a view counter at every refresh. I have a use-case where each view is unique to the IP so it's a bit more complex than increasing the counter ever refresh.

In my case I need to track views for multiple models, so I created a polymorphic table called Views and I have a trait I can add to each model that gives me access to the Views relation as well as some helpers to increase views.

Inside those helpers takes care of checking against IP and logging, essentially it checks if there's been a view form the same IP to the same page in the last X mins/hours/day, if so it doesn't log the view. This can of course be changed to use a cookie (set a cookie when viewing, check for cookie if viewing again, etc) to cut down on DB calls.

Another way to do it is queue the view calls (bonus you can do logic in there). This way you don't necessarily lock the table your updating views on, i.e. if your keeping a view_counton the model in question, if two people viewed at the same time and you tried to up the count at the same time, you may run into table lock issues.

Queueing them to record (and using Laravel's increment tool) along with making sure they get called one at a time, will avoid the table lock issue, allow you a place to do some logic and offload the heavy lifting/checking to another server/queue runner.

If it's a low traffic site, you can just increment each refresh, again it depends on your requirements and preferences.

28 Mar
4 weeks ago

Braunson left a reply on Laravel Homestead With Apache Server

Check the docs :)

Specifically under "Adding Additional Sites > Site Type"

Homestead supports several types of sites which allow you to easily run projects that are not based on Laravel. For example, let's add the apache type..

    - map: project.test
      to: /home/vagrant/code/my-project/web
      type: "apache"

Also check out "Web Servers"

Homestead uses the Nginx web server by default. However, it can install Apache if apache is specified as a site type. While both web servers can be installed at the same time, they cannot both be running at the same time. The flip shell command is available to ease the process of switching between web servers. The flip command automatically determines which web server is running, shuts it off, and then starts the other server. To use this command, SSH into your Homestead machine and run the command in your terminal:



20 Mar
1 month ago

Braunson left a reply on Can't Update Config File

Config::set will set the value for runtime only. It won't save it to the config file.

If you want persistent configurations take a look at Update Config on Runtime Persistently

Braunson left a reply on How Search For Multiple Words In Eloquent?

If you wanted to use space as the the delimiter.. something like this

$query = Input::get('q'); //  'john doe';

// Let's split on 1+ whitespace & ignore empty (eg. trailing space)
$searchValues = preg_split('/\s+/', $query, -1, PREG_SPLIT_NO_EMPTY); 

$deviceInspections  = DeviceInspection::whereHas('sale', function ($query) use ($searchValues) {
    foreach ($searchValues as $value) {
        $query->orWhere('sale_number', 'like', "%{$value}%");
18 Mar
1 month ago

Braunson left a reply on Running Multiple Homestead Instances

Soo sorta. You can specify the (Homestead Supported) version of PHP you want in the Homestead.yaml file. However for 5.6 since that's no longer supported in Homestead, there's a (paid) option like Homestead Fifty Six which you can check out here

Alternative options are using a Docker image or creating your own unfortunately :(

Braunson left a reply on What Happens To Team Subscription When Team Is Deleted?

Looking at the latest Spark code, when deleting a team, the event TeamDeleted is fired which has a listener called UpdateOwnerSubscriptionQuantity called.

Looks like it decreases the subscription there BUT only if your are charging PER SEAT. I agree if a team is deleted, it should cancel the Stripe subscription.

13 Mar
1 month ago

Braunson left a reply on Laravel Equivalent Helpers For Javascript

I haven't found any up to date NPM packages or plugins that do this. It would make a great package to build to match all (or most) helpers in Laravel but in JS :)

This library has pretty much all implementations of PHP functions in JS. So if you deconstruct the Laravel helpers and use this library, you can build a pretty closely matching NPM package!

Braunson left a reply on How To Remove The # Tag Url In The Production Mode Angular Version 1.7.3

This is probably better in #javascript but if we check the docs for Angular, you'll want this info

In your code you'll want to find something like this..

RouterModule.forRoot(routes, { useHash: true })

Then change the boolean to false for useHash ;-)

Braunson left a reply on Queue:Restart Problem

Try clearing your framework cache

Braunson left a reply on Forge's File

A .swp file is ot a swap file in the OS sense but instead a state file. A type of lock file. It keeps your changes since the last save, buffers you have saved, unsaved macros, and undo structure.

Typically they are created with vim and should automatically be deleted when VIM is closed and exited.

Get in touch with Forge support and see if it's one of their files open perhaps otherwise I'd probably delete it.

Braunson left a reply on Date|Time|Timezone Best Practices?

Store everything as UTC, then set the timezone per user when they login. Laravel will take care of the rest. Here's some helpful links..

There are many other threads about this on the forum, give it a search :)

Braunson left a reply on Could Not Open Input File: /home/forge/

What user is it running as on Forge? I'm using the same syntax but Forge is the user running the task..

11 Mar
1 month ago

Braunson left a reply on Not Allow A User To Fill A Form Input Unless Previous Input Is Valid

Something like this..

var input1= document.getElementById("input1");
input1.onchange = function () {
   if (this.value != "" || this.value.length > 0) {
      document.getElementById("input2").disabled = false;
   } else {
      document.getElementById("input2").disabled = true;
02 Mar
1 month ago

Braunson left a reply on Create A Code With Expiration Time

You'll likely want to use something like Twilio to do this.. check this guide out

28 Feb
1 month ago

Braunson left a reply on Mysql Not Restarting

First look would be to run journalctl -xe for details on WHY it's not loading, that should give you a starting point of where to look/whats going.

Braunson left a reply on After Installing New Nova:card Found 27 Vulnerabilities (1 High)

Well you have to find out what the vulnerabilities are. Run npm audit to see more details, from there you can make a judgement call (and/or post here).

While we don't know what they are, you do have 1 high which is what I'd probably focus on first to see what it is.

16 Feb
2 months ago

Braunson left a reply on Nested Object In Response API

Use the with method :)

15 Feb
2 months ago

Braunson left a reply on Ternery Operator Help

Ok let's break down this code, specifically everything inside the {{ }}

!empty($make->status)?($make->status==1)? 'selected':'':'selected'

The code is likely to not work as it's missing some brackets, technically this is a shorthand if statement. Really in longform what it's doing is..

// Is the make status FILLED?
if (! empty($make->status) {
        // Is the status == 1?
    if ($make->status == 1) {
            return 'selected';
        // else no it isnt
        } else {
                return '';
// else default to selected
} else {
    return 'selected';

What you instead want is this line..

! empty($make->status) ? ($make->status == 1 ? 'selected' : '') : 'selected'

Used like so:

<option value="1" {{ ! empty($make->status) ? ($make->status == 1 ? 'selected' : '') : 'selected' }} >Active

If you wanted to visually break it down for easier understanding..

! empty($make->status) ? // If the status is not empty then run the line below
    // check if status == 1 and if so return 'selected' otherwise return nothing
    ($make->status == 1 ? 'selected' : '') 
: // else
    // return selected

Hope this helps you understand the statement better.

Braunson left a reply on Homestead : Homestead.yaml Config

This is what you want to do. You have to map your projects folder to a folder on the Virtual Machine/Homestead, that's under folders. Then you need to map a domain from the VM/Homestead to a folder within the VM which is undersites

So we first map the folder from LOCAL machine to VIRTUAL machine. Then we map a site from DOMAIN to VIRTUAL machine folder (that was previously mapped out from LOCAL machine the step before.

    - map: "D:/iaccs-admin-console"
      to: "/home/vagrant/code"

    - map: notification.test
      to: "/home/vagrant/code/public"

Then all you have to do is up the VM and add to your hosts file the IP from the Homestead.yaml file with your domain you defined under sites.

// in your hosts file notifications.test

Braunson left a reply on Spark - Eloquent Relationships For Teams

Well this depends on what you want to do? Do you need to know which user from X team created it? Are you using that information (the user of the project) for any reason? If yes record both the user and team, otherwise just stick with the team.

13 Feb
2 months ago

Braunson left a reply on How Can Be Validated Any File Type In Laravel ?

You can only validate file (mime) type (not the contents of the file).

Check this for Mime Type

Check this for Mime Type by File Extension

11 Feb
2 months ago

Braunson left a reply on WhereNotIn Not Working

whereNotIn is not valid. You'd typically use whereIn with an array for example:

->whereIn('type', ['completed', 'failed', 'pending'])

Since you want to get all bookings that don't have error as the Payment_Status you would simply do this.

->where('Payment_Status', '!=', 'error');

Braunson left a reply on Get URL Changed By Pushstate

The reason your seeing the repeating ?page is because your getting the HREF which is getting the protocol, domain and any params.

Instead try something like this (with window.location.origin)..

function updateUrl() {
    history.pushState(null, null, `$(location.origin)/?page=` +;

Braunson left a reply on Add Blank Spaces In A String For Input Value

Not a simple solution snippet but check this out for a simple (as they type) custom text mask in Vue.

10 Feb
2 months ago

Braunson left a reply on Laravel 5.7 : Clean Way To Apply Policy Scope Based On User Role

Try this :)

function scopeAdminAuthor($query)
    return $query->when(auth()->user()->isAdmin(), function ($q) {
            return $q->where('author_id', 'auth()->user()->id);