8
Cả hai phương pháp dường như để tạo ra một kỷ lục mới nếu không tồn tại hoặc cập nhật một kỷ lục với dữ liệu được cung cấpsự khác biệt giữa updateOrCreate() và updateOrInsert() trong laravel 5.4
Cả hai phương pháp dường như để tạo ra một kỷ lục mới nếu không tồn tại hoặc cập nhật một kỷ lục với dữ liệu được cung cấpsự khác biệt giữa updateOrCreate() và updateOrInsert() trong laravel 5.4
updateOrCreate
là phương pháp Eloquent Builder và updateOrInsert
là phương pháp là gì Query Builder. mô hình
updateOrCreate
lợi nhuận, trong khi lợi nhuận updateOrInsert
boolean
Signatures từ mã Laravel:
updateOrCreate
/**
* Create or update a record matching the attributes, and fill it with values.
*
* @param array $attributes
* @param array $values
* @return \Illuminate\Database\Eloquent\Model
*/
public function updateOrCreate(array $attributes, array $values = [])
updateOrInsert
/**
* Insert or update a record matching the attributes, and fill it with values.
*
* @param array $attributes
* @param array $values
* @return bool
*/
public function updateOrInsert(array $attributes, array $values = [])