What are the available options for the Eloquent Model :: save () method?

Eloquent has a method called save()that takes an optional array of parameters (options). However, the API link does not seem to explain what these options are.

Is there a list somewhere that I'm missing? Of course, I could track them by the source code (at least I see touchand timestamp), but I decided that at least this question would be useful as a reference to others.

+4
source share
1 answer

TL; dr

In the array, $optionsyou can turn off the timestamp for this particular request:

$item->save([
    'timestamps' => false, // Disable timestamping on insert and update.
    'touch'      => false, // Disable parent timestamping.
]);

. : .
. 5.3 timestamps .

, , save() $options :

  • timestamps performInsert() performUpdate().
  • touch finishSave().

timestamps

performInsert() performUpdate() timestamps $options $timestamps :

if ($this->timestamps && Arr::get($options, 'timestamps', true))

, .

- , $option['timestamps'] true , ( ) - , . : , - .

. performInsert() 5.3 performInsert() performUpdate() $options.

touch

false, , $touches. true, , timestamps .

+5

Source: https://habr.com/ru/post/1609820/


All Articles