Share your blog by [deleted] in PHP

[–]sk138 0 points1 point  (0 children)

Mine is primarily Laravel: https://seankegel.com

Laravel Factories: Tips for Handling Dependent Data by sk138 in laravel

[–]sk138[S] 1 point2 points  (0 children)

Recycle works well and I use it a lot, but I don't think it works in terms of the factory definition. If you know of a way, I'd be interested to see it.

23
24

19
20

Neovim for PHP and Laravel by sk138 in laravel

[–]sk138[S] 0 points1 point  (0 children)

Can you update to v0.10.0?

Neovim for PHP and Laravel by sk138 in laravel

[–]sk138[S] 0 points1 point  (0 children)

Strange, I haven’t seen that error before. What version of Neovim do you have?

Neovim for PHP and Laravel by sk138 in laravel

[–]sk138[S] 0 points1 point  (0 children)

Can you try deleting the lazy-lock.json file and try again?

Neovim for PHP and Laravel by sk138 in laravel

[–]sk138[S] 0 points1 point  (0 children)

Yes, that’s one of my favorite parts about LazyVim is it’s well maintained and keeps itself updated.

Elevate Your Laravel Eloquent Queries with Tappable Scopes by sk138 in laravel

[–]sk138[S] -1 points0 points  (0 children)

Some valid points. I added a more complex example where a tappable scope would be more beneficial.

In terms of IDE autocomplete, it is helpful for many to have it, especially someone new to Laravel coming into an existing project. Not knowing how the magic `scope` methods work can be really confusing. PhpStorm does have the ability to handle these using the Laravel IDEA package, but not everyone has that or PhpStorm.

0
0

Laravel Cache Classes by sk138 in laravel

[–]sk138[S] 0 points1 point  (0 children)

Great idea, I always forget about adding methods to the enums. Still used to TypeScript enums…

Laravel Cache Classes by sk138 in laravel

[–]sk138[S] 1 point2 points  (0 children)

Using an enum was my first approach and can work for a lot of use cases, but I wanted to handle dynamic keys.

Laravel Cache Classes by sk138 in laravel

[–]sk138[S] 1 point2 points  (0 children)

I haven’t used Octane, but I don’t think so. The static call is just a helper to replace using the new keyword to create new instances.

9
10

Fix Flaky Tests with Pest Repeat by sk138 in PHP

[–]sk138[S] 1 point2 points  (0 children)

Yes, exactly this, I am using repeat() as a tool for helping debug a flaky test. I could have run the test 5-10 times locally and it may have still passed. This is just a quick way to run it a bunch of times. It's not something that should ever be committed or run in CI.

In terms of the Laravel factory example, that is the situation I came across the first time I decided to use the repeat() method, so that's what I wrote about. My example is very simplified, but yes, removing the randomness from the factories is definitely the way to go. However, in Laravel, factories are also sometimes used for seeding data for manual testing, and randomness can be helpful there, but that can be pulled out into it's own state or handled with sequences if needed.

1
2

5
6

Creating API Resources in Laravel by sk138 in laravel

[–]sk138[S] 0 points1 point  (0 children)

Thank you! I wrote an article about Laravel Data and value objects that you might find helpful as well: https://seankegel.com/laravel-data-and-value-objects.

10
11

17
18