fastsol

fastsol

Member Since 3 Months Ago

Experience Points
80
Total
Experience

4,920 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
0
Lessons
Completed
Best Reply Awards
0
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 1
80 XP
10 Jul
2 months ago

fastsol left a reply on Redirecting Old URLs To New Routes

This worked slick without any htaccess hacks. This is what I did to handle GET parameters that I needed to change around Route::redirect('quotes.php', 'quote/'.request()['quote-id'] ?? ''.'/'.request()['c'] ?? '');

14 Jun
3 months ago

fastsol left a reply on Request()->path() Incorrect During Testing

After a lot of frustrating testing and messing around the answer ended up being rather simple. All I needed to do was move the request() check to inside the IsActiveScope itself.

class IsActiveScope implements Scope
{
    /**
     * @param Builder $builder
     * @param Model $model
     * @return Builder|void
     */
    public function apply(Builder $builder, Model $model)
    {
        if(!request()->is('admin/*')) {
            return $builder->where($model->getTable() . '.active', '=', 1);
        }

        return $builder;
    }
}

and then in the model boot I changed to just this:

public static function boot(){
        parent::boot();

        static::addGlobalScope(new IsActiveScope());
}
11 Jun
3 months ago

fastsol left a reply on Testing Json And Enum Column Types With Sqlite

This is what I used and it worked great. I'm migrating 40+ tables that would take around a full minute to setup at the start of each testing session. This method makes it drastically faster. https://alexvanderbist.com/posts/2019/how-migrations-might-be-slowing-down-your-laravel-tests

fastsol started a new conversation Request()->path() Incorrect During Testing

I am having a hard time figuring out a way to set the pathInfo within the request when testing. Here is the scenario: I am adding a global scope to a model in the boot() of that model that is conditional based on the route that given. This works great under normal usage but testing it fails the condition because the pathInfo within the request is only "/".

What I don't understand is that AFTER the response is returned from the $this->get() in the test, the request has all the correct data, but it is NOT populated beforehand at the route model binding level. It is populated by the time it hits the middleware, but that is too late to attach or not attach a global scope for a route model binding situation.

The page in question is protected behind auth middleware, so the $this->fakeUser(); is simply a quick function to be() a user;

Here is the model code:

public static function boot(){
        parent::boot();

        if(!request()->is('admin/*')){
            static::addGlobalScope(new IsActiveScope());
            dd(request()->path());
        }
    }

As you can see the code is just checking if the route is "admin/*", so any admin pages essentially. But not matter what I have tried, the route always comes through as "/" when it hits that piece of code and the route model binding level. If you do a dd(request()); AFTER the $response in the test, the route has been populated at that point and is correct. This is the test:

/** @test */
    public function see_correct_active_icons_for_each_brand()
    {
        $this->fakeUser();

        $brand1 = factory(Brand::class)->create(['name' => 'A', 'active' => true]);
        $brand2 = factory(Brand::class)->create(['name' => 'B', 'active' => false]);
        $brand3 = factory(Brand::class)->create(['name' => 'C', 'active' => true]);

        $response = $this->get(route('admin.brands.index'));
        
        $response->assertSeeInOrder([$brand1->displayStatus(),$brand2->displayStatus(), $brand3->displayStatus()]);
    }

How can I fake this or is there another way to add the global scope in the manner that works like I have it now?