๐Ÿ‹๏ธ
Lift for Laravel
View on GitHub
  • ๐Ÿ‹๏ธLift for Laravel
  • ๐Ÿš€Getting Started
    • Installation
    • Changelog
  • ๐Ÿ› ๏ธAttributes
    • Cast
    • Column
    • Config
    • DB
    • Events
    • Fillable
    • Hidden
    • Ignore Properties
    • Immutable
    • Primary Key
    • Relationships
    • Validation
    • Watch
  • ๐ŸงชMethods
    • castAndCreate
    • castAndFill
    • castAndSet
    • castAndUpdate
    • createValidationMessages
    • createValidationRules
    • customColumns
    • defaultValues
    • immutableProperties
    • updateValidationMessages
    • updateValidationRules
    • validationMessages
    • validationRules
    • watchedProperties
  • ๐Ÿค–Commands
    • lift:migration
Powered by GitBook
On this page

Was this helpful?

  1. Methods

castAndUpdate

A replacement for the update method. It will cast your public properties and update the model instance.

$product = Product::query()->find(1);
$product->castAndUpdate([
    'name' => 'Product 1',
    'price' => '10.99',
    'category_id' => '1',
    'is_active' => 1,
    'promotion_expires_at' => '2023-12-31 23:59:59',
    'json_column' => ['foo' => 'bar'],
]);
PreviouscastAndSetNextcreateValidationMessages

Last updated 1 year ago

Was this helpful?

๐Ÿงช