# |
Sep 30th 2016, 17:34 |
inoas |
even then you can create classes instead of traits @ attaching them... but only via the callbacks basically |
# |
Sep 30th 2016, 17:33 |
watermark |
thanks for the input |
# |
Sep 30th 2016, 17:33 |
inoas |
but behaviors come with loading multiple files |
# |
Sep 30th 2016, 17:33 |
inoas |
well I don't really know tbh |
# |
Sep 30th 2016, 17:33 |
hmic |
and if you need/want to attach them to very different kind of classes too (like a controller *and* a table, think of configtrait or logtrait) |
# |
Sep 30th 2016, 17:33 |
inoas |
yes traits are faster |
# |
Sep 30th 2016, 17:33 |
watermark |
I assumed traits would be faster and didn't see any reason to favor a behavior (in most cases) |
# |
Sep 30th 2016, 17:32 |
inoas |
share a function across two classes that already inherit from different classes etc |
# |
Sep 30th 2016, 17:32 |
hmic |
as mixins, like inoas said, they are good too |
# |
Sep 30th 2016, 17:32 |
hmic |
so for very simple things, it might be a trait |
# |
Sep 30th 2016, 17:32 |
inoas |
I like to use them when I want multiple inheritance |
# |
Sep 30th 2016, 17:32 |
hmic |
watermark, traits are "smaller" usually. less overhead |
# |
Sep 30th 2016, 17:32 |
inoas |
personally i have to say, omit traits whereever possible |
# |
Sep 30th 2016, 17:31 |
watermark |
Opinion time. When either a trait or behavior will work, should I always favor using a trait? |
# |
Sep 30th 2016, 16:44 |
ndm |
http://book.cakephp.org/3.0/en/orm/associations.html#belongstomany-associations (see `saveStrategy`) |
# |
Sep 30th 2016, 16:43 |
ndm |
http://book.cakephp.org/3.0/en/orm/saving-data.html#unlink-many-to-many-records |
# |
Sep 30th 2016, 16:43 |
ndm |
@str use the associations `ulink()` method, or the save replace save strategy and set the property to an empty array |
# |
Sep 30th 2016, 16:42 |
inoas |
is there a reason there is no targetBindingKey for belongsToMany? |
# |
Sep 30th 2016, 16:36 |
str |
Didn't work :( |
# |
Sep 30th 2016, 16:36 |
str |
$this->Users->save($user); |
# |
Sep 30th 2016, 16:36 |
str |
unset($user->partners[0]); |
# |
Sep 30th 2016, 16:11 |
str |
Neon1024, I tried the unset, and got: Call to undefined method App\Model\Entity\User::unset() |
# |
Sep 30th 2016, 15:36 |
Neon1024 |
!tias |
# |
Sep 30th 2016, 15:23 |
birdy247 |
would it return a row if the placement had been softDeleted |
# |
Sep 30th 2016, 15:23 |
birdy247 |
if I were to do $this->Timetables->find()->innerJoinWith('Placements) |
# |
Sep 30th 2016, 15:23 |
birdy247 |
lets say a placement that hasMany timetables |
# |
Sep 30th 2016, 15:22 |
birdy247 |
and I have soft Deleted a record |
# |
Sep 30th 2016, 15:22 |
birdy247 |
but If I am using the trash plugin |
# |
Sep 30th 2016, 15:22 |
birdy247 |
This might be an easy answer |
# |
Sep 30th 2016, 15:22 |
birdy247 |
Neon1024 |
# |
Sep 30th 2016, 15:20 |
str |
$user->unset('partner')->save(); or just the unset? |
# |
Sep 30th 2016, 15:20 |
Neon1024 |
$user->unset(â??partnerâ??) |
# |
Sep 30th 2016, 15:20 |
Neon1024 |
Of it one is set |
# |
Sep 30th 2016, 15:20 |
Neon1024 |
Donâ??t assign a Partner entity to the User entity |
# |
Sep 30th 2016, 15:19 |
str |
If I have Users BelongsToMany Partners. and I wnat to remove the link for a specific user and leave that user with no partner, how do I do that? |
# |
Sep 30th 2016, 15:18 |
str |
Hi! |
# |
Sep 30th 2016, 15:09 |
Neon1024 |
In some cases but only if I felt it was relevant. I donâ??t think there is a hard and fast rule though |
# |
Sep 30th 2016, 14:59 |
djbuss |
would you use load model instead ? |
# |
Sep 30th 2016, 14:59 |
Neon1024 |
Perhaps I should be calling a method instead |
# |
Sep 30th 2016, 14:58 |
Neon1024 |
If youâ??ve got that many though, Iâ??d stop and think, why am I traversing so many models |
# |
Sep 30th 2016, 14:58 |
Neon1024 |
Nope |