Member Since 5 Years Ago


Founder / Lead Developer at

Experience Points 65,710
Experience Level 14

4,290 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 669
Best Reply Awards 17
Best Reply
  • 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.


    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.


    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.

05 Mar
5 months ago

laurence left a reply on How To Correctly Use Laravel With SQL Server Instead On MySQL?

The answer is to use unprepared like this:

DB::unprepared('SET IDENTITY_INSERT test_table ON');
DB::table('test_table')->insert(['id' => 1, 'name' => 'example']);
DB::unprepared('SET IDENTITY_INSERT test_table OFF');

You can see the GitHub thread about it here:

13 Feb
1 year ago

laurence left a reply on Is (only) CSRF Middleware Ignored For Testing? Did This Change At Some Point?

Only CSRF is specifically excluded during testing.

The reason is for convincence. Otherwise everytime you did something like this:

$response = $this->withHeaders([
            'X-Header' => 'Value',
        ])->json('POST', '/user', ['name' => 'Sally']);

you would have to do

$response = $this->withHeaders([
            'X-Header' => 'Value',
        ])->json('POST', '/user', ['name' => 'Sally', '_csrf_token' => csrf_token()]);

which would be tidious after a while

26 Aug
1 year ago

laurence left a reply on Laravel And Master-Slave Replication Lag

In Laravel 5.5 I've done a PR for a "sticky" option for replicated read/write databases.

It means your application will use the "read" connection whenever possible, but if you do a "write", then any subsequent "reads" on the same request cycle will also come from the write connection.

This ensures data integrity.

20 Aug
2 years ago

laurence left a reply on Securing Laravel API Endpoint/s For Angular App

Whilst you can make it harder - it is impossible to prevent a non-app from using your APIs. As soon as you send a token etc to the client, they could sniff this and use it themselves to manually send API requests.

Your best bet is to use good authentication on the backend, and perhaps use rate-limiting to prevent your API being used more than you intended for each user.

laurence left a reply on Cashier Reminders For Upcoming Payments

Stripe can handle this for you.

If you check out:

You can create an event for upcoming invoices. This event can then trigger your webhook, so your application can send an email (or do whatever you want).

laurence left a reply on Watch Directory For New Files

It probably depends what and how the "new" file is placed there? Is it being placed there by your application? If so - then you can trigger an event at the time the file is placed.

If some other service is placing the file there, the other option is can they hit a webhook when the file is done? That way it will trigger your process to run the file?

Otherwise I think your current solution is probably the easiest...

laurence left a reply on Nested Resources.. How Are People Implementing

Personally I always do implicit routing. It avoids all these issues, and makes it easier to see all the routes in your application.

This blog post by Phil is a great read on the topic:

19 Aug
2 years ago

laurence left a reply on Scheduler PingBefore() Does Not Seem To Work

In 5.4 the callback event does not call the before hooks. This has been fixed in 5.5

You can either upgrade to 5.5, or continue to use 5.4, but switch to putting the tasks into "commands" - which correctly uses the before hooks.

The other option is to switch to pingAfter() - that'll work as is.

laurence left a reply on Forge Stuck On "Listening For Events..."

I've not had any issues with Forge the past 24 hours.

Have you tried creating a server etc? Sometimes the listening for events is the normal screen while waiting for an action?

Otherwise Taylor normally gets back to people within 1-2 days in my experience.

laurence left a reply on Storage Recommendation?

Like many things - it really "depends" on lots of factors.

Generally speaking - if you dont have too many assets - you can probably just host them on your current DigitalOcean server.

Using a package like Spatie Backup - you can then regularly backup your application and database to S3 - that way you are protected from failures etc.

laurence left a reply on AssertSee + Escaped Output

Yeah - I've had this problem as well.

Best to make the assertion include the escaping. In a way - this is actually part of the test (because you are in fact doing an escaped text).

I just do assertSee(e($name)) - that way it is clear of the intention

laurence left a reply on Laravel Artisan Commands From Route Times Out

When you call an Artisan command from the web - this is NOT the same thing as calling an Artisan command via the CLI.

When you call the Artisan command from the web, you are still bound by the 60s (or whatever is in your .ini file) timeout rules. When you run it directly via the CLI - it can run indefinitely.

As JMarcher said - this code really belongs in a job. When you call the web page - it should fire the job onto a queue. That will allow the web page to return immediately - and the job will then process in the background.

laurence left a reply on Notifications Vs Flash Messages

You kind of answered your own question. A "flash" message means it is available for the next request only. It is only used to display a message on the screen to a user. It cannot be used to send SMS etc.

So flash messages are used for things like validation errors, or messages such as "your document has been saved" etc. They are forgotten and not saved.

You would not generally use notifications for these types of messages. Notifications are best for alerting "outside" your application - i.e. to email, SMS etc. Notifications are also stored, so you could display a history in your application etc.

There is nothing wrong with an event causes a flash message (to display the task complete) and also sending a notification to email, SMS etc.

16 Aug
2 years ago

laurence left a reply on Application Monitoring For Laravel 5

If you are still looking for a solution - I've built that is specifically built to monitor Laravel applications.

It will monitor your cron schedules, queues, logs, database, security etc.

There are the options for different types of notifications (Slack, Email, Telegram etc), and you can also have "teams" for different applications.

laurence left a reply on Telling Vagrant Which Box To Run

If you upgrade your Homestead box to v6 or above - you automatically get multiple PHP versions installed by default. Means you only need the one box, but can run different versions.

Check the Laravel docs for more info:

laurence left a reply on Multiple PHP Versions Homestead

In case people find this post - the answer has changed.

If you run Homestead v6 or above - you automatically get multiple PHP versions installed by default.

Check the Laravel docs for more info:

09 Aug
2 years ago

laurence left a reply on Custom 500 Page Not Shown On Production Environment

What does the Apache 500 error log say?

01 Jun
2 years ago

laurence left a reply on How Could This Happen? SQL Display Output To End User.

What DB driver are you using? Some are case sensitive.

So in some cases unqiue validation does not work

24 May
2 years ago
22 May
2 years ago

laurence left a reply on Homestead VMware On W10

You need to do

vagrant up --provider vmware_desktop

laurence left a reply on Homestead VMware On W10

I'm using VMWare with Windows 10. You need the "Workstation" edition.

At the moment I'm using Vagrant 1.9.0 (I couldnt get 1.9.2 or 1.9.3 to work).

Your Homestead.yaml file should be something like this:

ip: ""
memory: 2048
cpus: 1
provider: vmware_workstation

authorize: c:/Users/Name/.ssh/

    - c:/Users/Name/.ssh/id_rsa

    - map: c:/www
      to: /home/vagrant/www
      type: smb

    - map: example.vm
      to: /home/vagrant/www/example/public

The the folder mapping type of smb

16 May
2 years ago

laurence left a reply on Laravel 5.4 How To Redirect Back Using `->withInput(['key' => $val])`

You would do it like this:

return redirect()->back()->withInput()->withMessage($with);

15 May
2 years ago

laurence left a reply on On Local(windows) Working Fine But On Server(ubuntu 16.04) Errors?

Probably because of "case sensitive" file names.

Make sure your file is exactly DataTableBase.php - otherwise it will fail on Unbuntu.

11 May
2 years ago

laurence left a reply on $errors Won't Be Populated When File Can't Be Uploaded

Do any $errors work in other parts of your app? Or is it just when there is a file upload (which is the error you linked to)?

Have you tried uploading a smaller file?

laurence left a reply on Echo Or Return For Sending Response()->json($data) To Ajax Call

You should always return the response/view and let Laravel handle it and let Laravel do the output.

If you echo out the data yourself in the controller, then the response cycle of the framework is interrupted, and you might run into other issues down the track. For example, cookies might not be set etc

10 May
2 years ago

laurence left a reply on The Only Supported Ciphers Are AES-128-CBC And AES-256-CBC

Do you have config:cache enabled?

Sounds like the config is failing to load correctly - which can occur in production if you dont have the config cached....

laurence left a reply on Reflectionexception In Container.php Line 780 - Class Does Not Exist

Is the file casenames all correct? i.e. - is it exactly GarageWarranty.php?

laurence left a reply on Laravel 5.1 Strange Session Behavior

If $profile['_source']['picture'] is not set - that might cause a PHP error, and maybe that is resulting in the session not being set?

If you are using PHP7 try this:

     <div style="background-image:url( '{{ $profile['_source']['picture'] ?? null }}' )"></div>


08 May
2 years ago

laurence left a reply on App.debug Not Evaluating To False

Have you tried running cache:clear and/or config:clear?

i.e. perhaps your config is cached with the old value?

laurence left a reply on SAAS Application

There is the official Spark package as one option:

laurence started a new conversation Delete


laurence left a reply on Logging Or Monitoring System In Laravel 5.2

I recently launched a new website that can do this for you.

It can monitor and alert about logs, queues, cron scheduler as well as other parts of your application, such as response time, expiring SSL certificates etc.

You can view your log files remotely, and even "tail" and view logs in real time from your server - all from your dashboard.

laurence left a reply on How To Scheduler An Job Class?

The best option for long term job scheduling (i.e. days or even weeks into the future) is a database table.

Insert the job, or model etc into a table. Place a "to be run" date/timestamp there.

Then write a separate cron command that is run once per hour/day etc - and have it query that table for any jobs that need to be processed. It can pull the job, delete the row off the table, and then process the job or push it onto a queue to be processed.

laurence left a reply on How Could This Happen? SQL Display Output To End User.

I think the bigger concern here is that regardless of the cause - you displayed a raw error to a user.

The only way I think that could occur is if you have APP_DEBUG=true - which you should never have in production.

Turn it to false before you worry about anything else. It is a major security risk to keep it enabled in production - and there is really no need ever.

laurence left a reply on Startup Looking For A Senior Laravel Dev / Architect To Do Some Review Before Major Upgrade

This sounds like a good place for

You can post your job as a contract and get people to apply.

Alternatively you could use someone like Tighten or Vehikl -

07 May
2 years ago

laurence left a reply on Carbon Exception Error

An alternative - if you want:

if ($month = $filters['month']) {
   try {
         $query->whereMonth('created_at', Carbon::parse($month)->month);
   } catch (\Exception $e) {

Will just silently ignore false data. The alternative is run it through the validator

laurence left a reply on Where To Put Business Logic For Custom 404 Pages?

Depending on what the logic is - you could put a randomPosts() scope on your Post class.

Then in your view just call Post::randomPosts()

laurence left a reply on Carbon Exception Error

You just need to run month through the validator:

laurence left a reply on Session Lifetime Timeout And Csrf Token Mismatch

In Laravel 5.5 it now provides a TokenMismatch error page, and returns a HTTP status of 419:

So you can create a custom 419.blade.php to display a TokenMismatch error - or you can handle it in your own way.

Ajax/SPA applications can listen for the 419 response code and handle accordingly.

laurence left a reply on CSRF Mismatch With A SPA Vue App

As a side point - in Laravel 5.5 the TokenMismatch error will now return a HTTP status of 419:

So you can set a Vue function that anytime you get a 419 response - you know the token is expired and can handle accordingly.

laurence left a reply on When To Use Queues And When To Avoid Queues!

Jobs sound like the perfect place.

Your controllers can 'dispatch' jobs. Not all jobs have to be queued, you can remove the queue trait and that means the job is processed in sync.

But helps to separate the logic

laurence left a reply on Laravel 5.4 TokenMismatchException In VerifyCsrfToken.php Line 68 On Some Device

Oh - I just re-read your issue.

The problem is nothing to do with tokens - the problem is your sessions. For whatever reason - your sessions are broken on the other computer. This shows as a token_mismatch error - because when your session breaks, your token is wrong by default.

Try a different session driver.

06 May
2 years ago

laurence left a reply on Remove Part Of The Text With Blade

What you are looking for is parse_url()

$url = parse_url("");
var_dump($url['host']);  // will give ""

You can then preg_replace or substring out the www. if needed:

$domain = preg_replace('/^www\./', '', $url['host']);
var_dump($domain); // will give ""

laurence left a reply on Laravel 5.4 TokenMismatchException In VerifyCsrfToken.php Line 68 On Some Device

This is a very long shot - what is the name of your cookie?

Is it the default laravel_session? If so - try and change it to laravelsession? Does that solve it?

laurence left a reply on Jobs Won't Dispatch Via Queue Worker

Are you sure your queue tube is default? What is in your configuration?

And is your application pushing to the default tube, or is it pushing to something else like - i.e. Queue()->on('email');?

laurence left a reply on OPCache And Verifying That PHP FPM Is Reloaded In The Deployment Script

You can click "view latest deployment log" in Forge to see the output of the last deployment.

You wont see anything if the reload was successful - but if there were any errors they would appear there (and Forge would also alert you).

So the absence of errors implies it worked.

You could also try this package - which would give you a status of your opcache:

laurence left a reply on Supervised Queue:listen Stops Working

One option I've seen mentioned by Joseph Siblier is to add queue:restart every hour - so that any potential memory leaks get cleaned up:

If you want to monitor your queues and know they are actually running correctly, you could look at (which is a site I made). If your queues stop working for any reason - you'll get notified.

laurence left a reply on Forge Server Network

What's happening when I turn on "Can Connect To"? How Forge enables network between server instances?

That is modifying the firewall rules, allowing the servers to talk directly to each other.

I want to use DigitalOcean loadbalancer but it does't work (no ping to loadbalancer in local network). I turned off firewall but it doesn't helps.

I had a similar issue with DO load balancers & forge servers. I had to use the TCP check (rather than http) to get it to work.

laurence left a reply on Provision As Load Balancer

I've recently started using the DO Load Balancer. I've found that works quite well for all my Forge servers. I like the simplicity that I dont need to worry about the Load Balancer at all for anything - DO handles it all (apart from the basic config).

laurence left a reply on Server Responding To IP Address In Browser

In your nginx config you can add this:

server {
        listen 80;
        server_name IP_ADDRESS;
        return 404;

That way if anyone tries to go to your IP address they will get a 404.

You can return anything you want there instead if you want a different response.