artisan tinker eloquent to do an update ... set ... = value Respuesta rápida To update a specific record in Laravel using Artisan Tinker and Eloquent , retrieve the model instance and assign the new value to the attribute, then call the save() method. $user = App\Models\User :: find ( 1 ); $user ->name = 'New Name' ; $user -> save (); Alternatively, you can use the update() method on a query builder instance for a direct database update without loading the model: App\Models\User :: where ( 'id' , 1 )-> update ([ 'name' => 'New Name' ]); Key Considerations: Mass Assignment : Ensure the attribute being updated is in the model's $fillable array, or use fill() before save() . Collections : If using ::all() or ::get() , you receive a collection. You must iterate through it or use ::find() to get a single model instance before calling save() . Persistence : Assigning a value (e.g., $user->name = '...' ) only changes the ob...
Programemos Cosas
Ideas y proyectos de informática.