yoeriboven

yoeriboven

Member Since 1 Year Ago

Experience Points
26,890
Total
Experience

3,110 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
254
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 6
26,890 XP
Oct
07
1 week ago
Activity icon

Replied to Eager Loading Not Possible

Yeah, both add a query. Independent from each other but also when done at the same time.

It turned out to be a package bug though.

Sep
25
3 weeks ago
Activity icon

Replied to Eager Loading Not Possible

Just tried auth()->user()->load('subscriptions') in the controller but that just adds a query.

Activity icon

Replied to Eager Loading Not Possible

@drewdan How would I do this in the controller? I'm currently not passing anything there. It just returns a view.

In my views I use auth()->user()->subscription('default').

Activity icon

Started a new Conversation Eager Loading Not Possible

I'm using Laravel Cashier Paddle (docs - package) and having some issues on eager loading.

I'm accessing the user's subscription multiple times on my settings page. This results in a separate query for every access.

According to Laravel Debugbar I'm making the same subscriptions request nine times.

This is the culprit:

auth()->user()->subscription('default')

How to eager load this query? Using protected $with = ['subscriptions'] on the User actually adds a query.

Here's the line in the package.

Activity icon

Awarded Best Reply on Add Items To Custom Collection

Now, I realize this doesn't work.

Every time you call a function on the collection a new one is returned using this constructor.

A better solution is to create a static constructor:

public static function withPlans()
{
    $plans = [
        new ProPlan(),
        new AgencyPlan(),
    ];

    return new static($plans);
}
Activity icon

Replied to Add Items To Custom Collection

Now, I realize this doesn't work.

Every time you call a function on the collection a new one is returned using this constructor.

A better solution is to create a static constructor:

public static function withPlans()
{
    $plans = [
        new ProPlan(),
        new AgencyPlan(),
    ];

    return new static($plans);
}
Sep
21
4 weeks ago
Activity icon

Started a new Conversation Test Validation Without HTTP Session

I'm picking up some techniques from Jetstream but testing isn't optimal.

Here's my action class and test.

namespace App\Actions;

class UpdateUserDetails
{
    public function update(User $user, array $input)
    {
        Validator::make($input, [
            'name' => 'required|min:3|max:50',
	    ...
        ])->validate();

        ...
    }
}
/** @test */
public function it_has_a_valid_name()
{
    try {
        (new UpdateUserDetails())->update($user, ['name' => null]);
    } catch (ValidationException $e) {
        $this->assertNotNull($e->errors('name'));
    }
}

This looks hideous. Especially when you want to make multiple assertions per test.

Jetstream tests like this:

/** @test */
public function it_has_a_valid_name()
{
    $this->expectException(ValidationException::class);

    (new UpdateUserDetails())->update($user, ['name' => null]);
}

My problem with this is that this test also passes if the name is fine but the e-mail is not allowed. It just looks at the exception and not the errors function on that exception.

Are there any methods to make my code a bit cleaner?

Sep
01
1 month ago
Activity icon

Replied to Add Items To Custom Collection

A bit too quick with posting a question here.

I didn't want to override the constructor because what happens when the constructor on the underlying class changes? I'd always have to check that class to see if something changed.

Then I remembered I could just call the constructor by myself like this:

public function __construct($items = [])
{
  $plans = [
    new ProPlan(),
    new AgencyPlan()
  ];

  parent::__construct($plans);
}
Activity icon

Started a new Conversation Add Items To Custom Collection

I'm building a custom collection class called Plans.

<?php

namespace App\Plans;

use Illuminate\Support\Collection;

class Plans extends Collection
{
  public function withStripeId(string $stripeId) {
    ...
  }
}

Plans has a few custom methods (like retrieving by stripe id) and should contain an object of each of my Plan classes.

It should be retrievable from the service container with the Plan objects already in it.

Illuminate\Support\Collection has an $items property but I can't instantiate the Plan objects there.

Is overriding the constructor my best bet here?

Aug
06
2 months ago
Activity icon

Replied to Socialite FB

Enable https on your virtual host.

Or use something like Homestead or Valet and use https there.

Activity icon

Replied to FaceBook Login

Surely there's documentation that came with the purchase.

Check the composer.json to see if they used Laravel Socialite. In that case you need to add some environment variables.

Here's the documentation for Laravel Socialite with Facebook.

Jul
15
3 months ago
Activity icon

Replied to Create API And Show Data With Laravel From Endpoint

Do you want us to write all of your code?

$response = Http::post('http://test.com/users', [
    'parksandrecreationapi' => 'api_key',
    'lati' => 'example_latitude',
    'long' => 'example_longitude',
]);

This should get you started.

Jul
06
3 months ago
Activity icon

Commented on Refactoring For Clarity

Great video. I did something similar by adding a notifyFollowers() method to a Channel object. Whenever a Channel had a new post, followers would be notified.

Got a question about your request object though. Could you show some more about that? Saw you had custom methods on it but most interestingly: selectedPlan was something like a Plan object? Since you did ->price on it.

How do you change it from a string in the POST request to an object?

May
01
5 months ago
Activity icon

Replied to Compare Carbon Without Milliseconds

Thought of that but it makes the test a bit ugly and as you said, it's rather strange this happens.

This happens in a package I'm building by the way. Using Orchestra.

Activity icon

Started a new Conversation Compare Carbon Without Milliseconds

In one of my models I'm casting to a Carbon instance.

protected $dates = [
    'some_date',
];

Here's my test:

public function it_saves_the_correct_datetime()
{
    $user = User::create();

    $this->assertEquals(now()->addDays(14), $user->some_date);
}

This test will fail because the first instance has milliseconds and the instance coming from the database has not.

Failed asserting that two DateTime objects are equal.
--- Expected
+++ Actual
@@ @@
-2020-05-15T15:00:07.305878+0000
+2020-05-15T15:00:07.000000+0000

To fix this I add this at the beginning of the test Carbon::setTestNow(now()->roundSecond()).

Anyone know a better way to compare two Carbon instance to each other without looking at the milliseconds?

Apr
23
5 months ago
Activity icon

Replied to PHPStorm Can't Find Can() Method On User

And it does so many other weird things.

Post::select('profile_id', \DB::raw('MAX(posted_at) AS max_date')) gives this warning: Method call is provided 2 parameters, but the method signature uses 1 parameters.

This also gives warnings (simplified example):

/*
 * @return \App\Post
 */
public function getPost()
{
   return Post::select('title')->first();
}

Return value is expected to be '\App\Post', '\Illuminate\Database\Eloquent\Model' Why is it not looking at the parent model of the Post class?

Activity icon

Replied to PHPStorm Can't Find Can() Method On User

No, can also doesn't work.

Activity icon

Started a new Conversation PHPStorm Can't Find Can() Method On User

I'm trying out PHPStorm for the first time and there are a lot of warnings in my code.

One of them is this one:

if (auth()->user()->canNot('delete', $post)) {
    return false;
}

PHPStorm gives this error: Method 'canNot' not found in \Illuminate\Contracts\Auth\Authenticatable|null .

I already installed barryvdh/laravel-ide-helper.

How to fix this?