pilat wrote a comment+100 XP
4mos 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 wrote a comment+100 XP
5mos 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 wrote a reply+100 XP
6mos 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],
]