View more context

 

nightjarnz

In terms of strong preference over update(...) or ->Field = ..., no I don't think there is one.

🤔 (1)
nightjarnz

I tend to prefer the former for brevity in calls. But it depends on how much you're trying to update at once really.

jakx

I lean towards the former too, to me it feels more elegant and somehow more SS "flavoured"

👍 (1)
nightjarnz

The wierd thing with the latter is that they're not actually properties too, which can (but not always) cause e.g. phpstan in vscode to underline all the things

😅 (1)
theruss

I tend to go for the former, but if I needed to do something similar to the latter, I prefer use of the setField() method. But you need to watch out that this also sets has_one's as well

😯 (1)
jkersu

Im curious, can you chain a write() directly after the update?

theruss

DataObject::update() returns an instance of the DataObject subclass

theruss
  1. * @param array $data A map of field name to data values to update.
  2. * @return DataObject $this
  3. */
  4. public function update($data)