Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pilat's avatar

pilat wrote a comment+100 XP

3mos ago

Everything New in Livewire 4: Ep 2, View-Based Components

3:00 - "including import statements".. hmm, that didn't work in beta. Will definitely try it tomorrow!

pilat's avatar

pilat wrote a comment+100 XP

4mos ago

Eloquent Relationships Deep Dive: Ep 1, One-to-One Relationships

You say it's the simplest relationship, but how do you enforce it? What if I write the same user-id into two different profile records? In this regard, HasMany and its BelongsTo companion are simpler to implement, because they don't promise to much ;)

pilat's avatar

pilat wrote a reply+100 XP

5mos ago

Deciding what item remains in a collection after unique method is applied

with unique(), the first item it stumbled upon will remain. BUT, this is not common for all the methods. In keyBy(), for example, the last item will replace anything before

$coll = [
    ['tag' => 1, 'value' => 11],
    ['tag' => 1, 'value' => 12],
    ['tag' => 2, 'value' => 21],
    ['tag' => 2, 'value' => 22],
];

[
    'unique' => collect($coll)->unique('tag')->pluck('value')->all(),
    // BUT!
    'keyBy' => collect($coll)->keyBy('tag')->pluck('value')->all(),
];

// output:
[
    "unique" => [11, 21],
    "keyBy" => [12, 22],
  ]
pilat's avatar

pilat wrote a reply+100 XP

5mos ago

Eloquent new vs make

Just wanted to mention this:

Larastan shouts on me:

 Called 'Model::make()' which performs unnecessary work, use 'new Model()'.
         🪪  larastan.noModelMake

So, I consider that someone has investigated this topic and came to conclusion that it makes sense to use new Model() syntax.