codeplumber's avatar

codeplumber liked a comment+100 XP

4w ago

@isimmons We could also have the alpine's @click.away="$dispatch('search:clear-results')"

codeplumber's avatar

codeplumber liked a comment+100 XP

1mo ago

@codeplumber, I agree that it reads better, but be aware of potential performance issues down the line.

Doing a GROUP BY like in the video delegates counting to the DB. This is something that DBs do all the time and is already fairly optimized. In this case, PHP receives already prepared counts for each of the categories.

Doing an ideas()->get()->countBy('status') will:

  1. Select rows from the database;
  2. Pass all of these rows from the DB to PHP;
  3. Load them as Eloquent models (the reason we have all of these different helper methods available); and
  4. Iterate over all of these Eloquent objects to get the count.

This is fine for a tutorial project, but it won't scale well down the line. While it would take 1000s of records to notice any real difference, I'd still suggest using the first approach. It's better to be safe than sorry.

codeplumber's avatar

codeplumber wrote a comment+100 XP

2mos ago

Just finished this series and I must say that despite I did not expect to learn much new stuff, I am left with multiple pages of what I expected to be almost empty markdown note. Thanks Jeffrey and good luck to everyone learning at Laracasts!

codeplumber's avatar

codeplumber wrote a comment+100 XP

2mos ago

@JeffreyWay You set the expectations too high for the rest of us, fixing bugs that fast! Thanks Jeffrey

codeplumber's avatar

codeplumber liked a comment+100 XP

2mos ago

It looks like the video cuts off too early (length of video is around 2mins). But the episode summary does show the completion of extraction of the modal.

codeplumber's avatar

codeplumber wrote a comment+100 XP

2mos ago

@mrrobotoh I have submitted a support ticket as it seems the issue is still here.

codeplumber's avatar

codeplumber wrote a comment+100 XP

3mos ago

As much as I like to practice array mapping and manipulation, countBy() helps to clean the logic up a bit:

// Get counts in the controller
'counts' => $request->user()->ideas()->get()->countBy('status');

// Get counts in view, including those with no records
{{ $counts[$ideaStatus->value] ?? 0 }}
codeplumber's avatar

codeplumber wrote a comment+100 XP

3mos ago

Color theme for those looking to copy:

    --color-background: oklch(0.12 0 0);
    --color-foreground: oklch(0.95 0 0);
    --color-card: oklch(0.16 0 0);
    --color-primary: oklch(0.65 0.15 160);
    --color-primary-foreground: oklch(0.12 0 0);
    --color-border: oklch(0.24 0 0);
    --color-input: oklch(0.24 0 0);
    --color-muted-foreground: oklch(0.6 0 0);
codeplumber's avatar

codeplumber wrote a comment+100 XP

3mos ago

Is 'password' => Hash::make($attributes['password']) truly needed when User model has this cast 'password' => 'hashed' by default? I know the clear password issue should be mentioned here but I think this is also an opportunity to mention casts.

codeplumber's avatar

codeplumber liked a comment+100 XP

3mos ago

One important thing when creating routes like that, is the order.

Route::get('/ideas/create', [IdeaController::class, 'index']);

Must be defined before

Route::get('/ideas/{idea}', [IdeaController::class, 'show']);

Or you will scratch your head as to why you get a 404 when trying to navigate to the create Idea route.

codeplumber's avatar

codeplumber wrote a comment+100 XP

3mos ago

@AdamBark These are just non-blocking deprecation warnings, likely because of the installer you're running has dependencies not yet ready for PHP 8.4 used in CLI. If you are bothered, update the installer in Herd and you should be good to go.

codeplumber's avatar

codeplumber wrote a comment+100 XP

3mos ago

Glad to see DaisyUI!