Member Since 3 Years Ago


Experience Points 15,590
Experience Level 4

4,410 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 141
Best Reply Awards 1
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.

23 Nov
1 year ago

andersfloor left a reply on Opengraph

I was looking for the same and found this question through Google. I was not able to find a usable Laravel package as of now so I made my own quick ' dirty scraper class based on Goutte (composer require weidner/goutte). Just in case someone finds this page through Google again:

use Goutte;

class OpenGraphScraper {

  private $url;
  private $crawler;
  public $tags;

  public function __construct($url) {
    $this->url = $url;
    $this->tags= $this->parseUrl();

  private function parseUrl()
    $this->crawler = Goutte::request('GET', $this->url);
    return [
      'site_name' => $this->getOgTag('site_name'),
      'type' => $this->getOgTag('type'),
      'title' => $this->getOgTag('title'),
      'description' => $this->getOgTag('description'),
      'image' => $this->getOgTag('image'),

  private function getOgTag($property)
    $metatag = 'meta[property="og:' . $property . '"]';
    if ($this->crawler->filter($metatag)->count()) {
        return trim($this->crawler
    return '';

$url = '';
$og = new OpenGraphScraper($url);
array:5 [▼
  "site_name" => "CNN"
  "type" => "article"
  "title" => "Search for Argentine submarine enters 'critical phase'"
  "description" => "The bad news: A missing Argentine submarine could be running low on air Wednesday. The good news: The weather is optimal for the multinational search, and if th ▶"
  "image" => ""
28 Sep
1 year ago

andersfloor left a reply on What Music Do You Listen To When You're Programming?

Oldies, folk, electronic, all kinds really. I often try out other people's Spotify playlists from to discover new artists in the meantime (Spotify's radio only plays a small collection of artists).

andersfloor started a new conversation Dusk Test Does Not See Database Update

I'm trying to replicate the Email verification lesson in Laravel 5.5 using Dusk for testing. I'm running into an issue where my test procedure does not see the database update after a user has confirmed his registration through the link.

This is my test procedure:

    public function test_a_user_may_register_but_must_confirm_email_address()
        $this->browse(function (Browser $browser) {
                ->type('name', 'JohnDoe')
                ->type('email', '[email protected]')
                ->type('password', 'password')
                ->type('password_confirmation', 'password')
                ->assertSee('Please check your inbox to confirm your registration');

        $this->assertDatabaseHas('users', ['name' =>'JohnDoe', 'verified' => false]);

        $user = User::whereName('JohnDoe')->first();

        $this->browse(function (Browser $browser) use ($user) {
             ->assertSee("Email verified!");

        // This is the line that's failing
        $this->assertDatabaseHas('users', ['name' =>'JohnDoe', 'verified' => true]);

Here is the controller:

    public function checkConfirmation($email_token)
        $user = User::whereEmailToken($email_token)->firstOrFail();
        $user->verified = true;
        $user->email_token = null;
        // note I'm adding the verified-attribute here
        dd("Email verified! " . $user->verified);


This is the artisan dusk output:

There was 1 failure:                                                                                                           
1) Tests\Browser\ExampleTest::test_a_user_may_register_but_must_confirm_email_address                                          
Failed asserting that a row in the table [users] matches the attributes {                                                      
    "name": "JohnDoe",                                                                                                         
    "verified": true                                                                                                           
Found: [                                                                                                                       
        "id": 1,                                                                                                               
        "name": "JohnDoe",                                                                                                     
        "email": "[email protected]",                                                                                        
        "password": "$2y$10$dMIS2MqW1MKNGc3lGKORROirp73q\/X.gyLv.bCzblxl3Wfq2spj6y",                                           
        "remember_token": null,                                                                                                
        "verified": 0,                                                                                                         
        "email_token": "S0vapdxiyL0nuEqiuT8rup24jlXHjL9B",                                                                     
        "google2fa_secret": null,                                                                                              
        "created_at": "2017-09-28 07:56:30",                                                                                   
        "updated_at": "2017-09-28 07:56:30"                                                                                    

So after completing the verification link the test finds that the user is not verified in the database. However, according to my database the user has been verified successfully and artisan tinker shows that as well..

If I change the line assertSee("Email verified!") to assertSee("foo") the screenschot shows that the user was verified:


I cannot chain the assertDatabaseHas to the $this->browse(...) because that returns a null.

If I take out the last assertDatabaseHas and put it in a separate function, the test succeeds:

        $this->browse(function (Browser $browser) use ($user) {
             ->assertSee("Email verified!");


    public function test_databasecheck_in_a_seperate_function()
        $this->assertDatabaseHas('users', ['name' =>'JohnDoe', 'verified' => true]);

... but I'd like to keep the database assertion in the same function as the other tests, since they belong together. Is that a bad idea? Am I doing something wrong or is dusk a bit wonky?

06 Nov
2 years ago

andersfloor left a reply on Laravel Is A Giant Waste Of Time

Well, since the topic is (unneccessarily) bumped, my 2 cents. I've been out of the PHP loop for the past 10 years, not having been programming at all. Wanting to build my own project, I did some reading PHP development anno 2016 . Within the first three hours of diving into Laravel, I knew it was gold. And I still think it is. However, I was completely new to composer. And to virtualbox. Vagrant. Homestead. Git. Node. Bower. Gulp. Elixir. Laravel. Artisan. And although I think the whining and complaining by dazed067 does not help him one bit, I fully understand his frustrations. Despite all the excellent resources from people like Jeffrey Way and Matt Stauffer, I found the learning curve gruesomely steep. There are very little resources aimed at a true newbee level. Virtually all tutorials assumed a basic level of understanding I simply didn't have.

Take Jeffrey's first fundamental video, for example. This is sort of what my reaction was to what he said. It's not meant as criticism, just as a transcript of what went on in my head

One of the best introductions in the PHP world is Composer, a dependency manager

A what?

In the past we had to use confusing tooling like Pear (Pair) but Composer makes the entire process easier

Ehh... What process?

So what does it do? It allows us to reuse code and download popular packages

Popular what? What are packages?

If you're curious about all the offerings, you can browse to

.. visited the site... completely baffled.. what's this about?

Maybe you want something to do with authentication.. or use a framework like codeception.. or behat.. or phpspec

Ehhmmm.. never heard of those but something tells me this sounds like something that could be interesting very much later on... But uhmm... I just like to download Laravel and get into it? And I'm guessing that packages are pieces of software/code?

And it includes laravel. Now, we have a couple of different ways we can pull in laravel. If you go to the cosumentation, you can find a command line tool that does something like laravel new my-blog and that is all you have to do.

All I have to do for what? Don't I need to download Laravel to use this command line tool? But that's just what I want to do. How do I download it?

However, if you want to instead pull it in through composer, here's how you can do it

Eeeuhmm... Do I want to pull it in through composer? Would I want that? Why? What is the advantage? I still don't understand what composer is. Which option should I choose?

But we have download composer first.

Ahhh pffff this is getting complicated. I guess it's good for something, but I'm still not sure what it does.

(After installation). Now we can set up a new project and require for example phpspec

Uhmm.. okay.. So I take it that composer is used to download software. Great. But why wouldn't I download and unzip phpspec manually, like the old days? I still don't get why it has to be so complicated. What on earth is the advantage of this? We're 5 minutes into the lesson about composer and still I don't have a clue what I need it for?

What I want you to note here is that phpspec itself has a number of dependencies. Notice that for each of the components there aready is a package available.

Hmm allright, I'm starting to understand that there could be something useful here. It's like a quick downloader? Still, I don't know that this has to do with laravel.

Let's list the files .Think of the composer.jswon file as a configuration file. If you give the project to someone else, they can simply do a composer install to pull in everything that I've specified right here.

Huh? If I give the project to someone else, why don't I just give him all the code? Why does it have to be so complicated?

Next, if we take a look at that vendor directory, any packages that we pulled in though composer will be placed right here

Vendor? Why not packages? But yes, I see that there are downloads here. Still don't really get it, I never had problems downloading and unzipping code.

Composer includes a very helpful autoloader out of the box. With the autoloader we can follow a basic convention which allows us to very easily import for example php classes that we might need.

.... I feel we're going deeper and deeper into the woods. It sounds like it's useful but it's going way over my head. Can't we just start with Laravel.... pleeeaaaaasssssseeee?


Once again, this is not meant as criticism, but merely to show how difficult things can be for newbees even despite very helpful resources like Laracasts.

Now, about 1500 hours later, my understanding of the matter completely changed and my largest project ever is live using all of the above software/methods. Largely thanks to Jeffrey, this forum, Matt Staufers blog and Taylor's Laravel documentation. Using composer, bower, gulp, artisan has become second nature now, but boy has it been a tough learning process. Much tougher than it should have been in hindsight. I think this comment I saw in this thread is exemplary of many resources on Laravel:

Anyone programming in PHP should be familiar with composer by now.

That's not how it works

We've all been newbees. We've all had to learn everything we know. And everyone's starting level is different. If I had started with Laravel with knowledge of composer, with knowledge of gulp, of dependency management, anything like that, the learning curve would have been much easier. But I didn't have that knowledge, so it was a extremely tough uphill struggle to make sense of it all.

Sure, I fully agree it's not neccessary to fire of a frustrated rant within a community. But while I can understand that people take offense at dazed067's message, I'm surprised by how few people here were able to see past that obvious moment of frustration and actually give constructive feedback, and surprised in how many people were just making fun of how easy it was to get into Laravel.

30 Oct
2 years ago

andersfloor left a reply on Social Sharing

I'm not quite sure what you mean. The client-side sharing method itself is pretty straighforward, and ShareThis does a good job at that. If you are looking to control what content is being shared, you should leverage the use of proper "social" meta-tags (open graph tags and twitter card tags).

In my experience it's best to generate these directly in your blade templates based on meta data you stored in the database, although there are packages that can help here like criskonnertz/open-graph. Be careful with user generated content in tags since it looks like it does not escape content.

andersfloor left a reply on How Do I Know That Taylor Doesn't Steal Or Access My Projects?

I don't think it's necessary to mock the topic starter's capabilities, no matter how good Taylor Otwell is.

I use Forge myself and feel that ThomasT has a valid point here. Forge's Terms of Service are remarkably flimsy and one sided There's almost no mention of Forges responsibilities, it's all about the user. It does not offer anything remotely resembling a SLA, in fact it literally does not offer any warranty of any kind. It could certainly use a Data Privacy clause, like most serious hosting providers offer.

That being said, no, there is nothing you can do to prevent Forge (or Taylor) from accessing your data. Forge has root access to your files and databases. The certainty you have is that Taylor cannot afford to risk it. He's got far more to lose from messing with your code than he could gain from it. That's what makes me comfortable enough to use Forge despite the thin ToS.

25 Oct
2 years ago

andersfloor left a reply on Laravel 5 Validation Request, How To Handle Validation On Update?

Laravel v5.3.18, recently released, has made some changes/improvements on this matter. Witigo mentioned it in his example. For more info see

24 Oct
2 years ago

andersfloor left a reply on Write Data To Db Based On User Input

I'm not quite sure if I understand you correctly, but I'd say add form fields "hours" and "bouy" and retrieve the corresponding $stats/$tide parameters within the store method after the validation

$this->validate($request, [.....]);

$sesh = new Sesh;
$sesh->findTidesAndStats($request); // create this new function in the Model
class Sesh {
  // add function that finds direction, size, duration and tide based on hours and buoy
  function findTidesAndStats($request)
    $hours = $request->hours;
    $buoy = $request->buoy;

    // retrieve $stats and $tide as you described
    // ....

    $this->direction= $stats->direction;
    $this->size= $stats->size;
    $this->duration= $stats->duration;
    $this->tide= $tide->somefield;

    return $this;

This solution means these 4 values are filled automatically without the user seeing them while filling out the form. I don't know if you intented it that way.

It might also be interesting to move some logic to the boot-method of the Sesh-model when you wish to set additional data automatically on creating a new instance. Check out

22 Oct
2 years ago

andersfloor left a reply on Sweetalert2 Getting It To Work

Btw, I use sweetalert2 a lot in my current project. I especially love the interactive possibilities combined with Ajax requests and chained sweetalert commands. It took me hours to figure this out and there's not much documentation to be found on this part, so let me share that here as well:

sweetalert2 popup with form field

Blade view:

    <a class="btn btn-lg btn-primary" id="addfriend" role="button">Add as friend</a>
var sa_title;
var sa_type;
var sa_msg;
var friendname = '{{$user->username}}'; // e.g. 'Eric'
var friendtitle = '{{ $user->HeShe ) }}'; // e.g. 'He' or 'She'

$(document).ready(function() {

    $('#addfriend').click(function() {
            title: 'Friendship request',
            text: 'You wish to send ' + friendname + ' a friendship request. If you want you can add a personal note.',
            type: 'info',
            input: 'textarea',
            confirmButtonText: 'Send request',
            showCancelButton: true,
            showLoaderOnConfirm: true,
            inputValidator: function(textarea) {
                return new Promise(function(resolve, reject) {
                    if (textarea.length>200) {
                        reject('Your text is too long. Please use no more than 200 characters.');
                    } else {
            preConfirm: function(textarea) {
                return new Promise(function(resolve, reject) {

                    // Make jQuery Ajax-request
                        data       : 'msg=' + textarea,
                        cache      : false,
                        processData: false,
                        dataType   : 'json',
                        method     : 'POST',
                        url        : '/async/addfriend/' + friendname,
                        success: function() {
                            // Set content for success-sweetalert
                            sa_title = 'Success!';
                            sa_msg = friendname + ' has received your request.';
                            sa_msg += friendtitle + ' needs to accept it first though.'
                            sa_type = 'success';
                        error: function(response) {
                            // Set content for failure-sweetalert
                            sa_title = 'Oops!';
                            sa_msg = 'Something went wrong. Please try again or contact us.';
                            sa_type = 'error';
                            reject('We were unable to process your request');
            allowOutsideClick: false
        }).then(function() {
                // Show success or failure sweetalert
                title: sa_title,
                html: sa_msg + "",
                type: sa_type
            }).then(function() {
                // Hide button
//          }).done(); // Deprecated, see comment by limonte below
//      }).done(); // Deprecated, see comment by limonte below


In this case, I make a post request to the url /async/addfriend/Eric - which should return a valid response or an error.

andersfloor left a reply on Sweetalert2 Getting It To Work

Javascript-libraries and Laravel are kind of two separate worlds. Laravel works server-side, javascript works client-side. With Laravel you create views (blade), and in those views you can call all the javascript and html that you want.

Imagine you start with a new project. Install the Infinety/alerts-package with the instructions as mentioned on their page.

Use this for example in your routes file (or in a controller):

Route::get('/', function () {
    // Simply shows the blade view resources/home.blade.php
    return view('home');

Route::post('/justapage', function() {

    // This is the message that will show in the sweetalert-popup:
    alert()->success('It worked!', 'The form was submitted');

    // Redirect back to the page you were looking at
    return back();

And use this as resources/home.blade.php:

<!DOCTYPE html>
<html lang="en">

    <!-- include sweetalert2 css library -->
    <link rel="stylesheet" type="text/css" href="">


    <form action="/justapage" method="post">
        {{ csrf_field() }}
        <button type="submit">Click me!</button>

    <!-- include sweetalert2 js library. Note: place it in the body, not in the head -->
    <script src=""></script>

    <!-- And is where Laravel and javascript come together -->
    <!-- This include basically writes the neccessary javascript: -->


(I used the sweetalert2-CDN-files here)

When you click the button, it should show the sweetalert2 popup Sweetalert2 popup

If you check out the source of the webpage, you will see that the @include('Alerts::alert')-line has outputted this javascript:

            title: "It worked!",
            text:  "The form was submitted",
            type: "success",
            timer: 2500,
            showConfirmButton: false

Instead of this:

alert()->success('Title', 'Message');

you can also use:

alert()->overlay('Title', 'Message', 'success');

-> this will add a close button to the sweetalert popup and prevent it from closing automatically.

andersfloor left a reply on Make Input Field Display None/block Based On Option Selected

That's not related to javascript. You might want to check your input names with the database column names. My guess is that your input name fallow_up_date should be follow_up_date.

21 Oct
2 years ago

andersfloor left a reply on Sweetalert2 Getting It To Work

It depends on what you want to to. Do you have problems getting the sweetalert popup to show, or are you looking to easily integrate it in your controllers? If that's what you want, there's a Laravel package that makes that part quite easy:

If you install it according to the instructions, it should work fine. Please note that it comes with the sweetalert js and css file, which will be put into the public folder when you execute the php artisan vendor:publish --tag=alerts command, so that might overwrite the files you already put into the public folder.

01 Mar
3 years ago

andersfloor left a reply on Please Solve This Easy Question Php

I don't really understand the question. Aren't you just looking for this function?

29 Feb
3 years ago

andersfloor left a reply on Migrate:rollback Not Working

I had the same issue yesterday. I ran

composer dump-autoload

based on this Stackoverflow-discussion, after which it worked again the way it should. Don't really know why though.

24 Feb
3 years ago

andersfloor left a reply on API Authentication Concepts

I'm pretty new to Laravel but I'm facing a similar challenge. I want a website and a mobile app to make calls to the same API for similar content. I'm probably going to use JWT tokens for user authentication from the app. You might find this article interesting: It's written for an AngularJS front-end but still gives good information for setup on the Laravel side.

I believe the bottom comment in the link you mentioned addresses the problem that is described here: That article mentions HVMC, a tool for making internal requests to an API. I'm thinking about using that. The current branch for Laravel 5.x is here: