Ir al contenido principal

Entradas

Laravel Database Query Builder and Model fillable array

  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...

Desarrollo de sistema gerencial (parte 7)

  Vamos con la Etapa 12: actualizar DatabaseSeeder y hacer la prueba final del flujo completo . 🎯 Objetivo de esta etapa Actualizar DatabaseSeeder para incluir los seeders base + el DemoSeeder Ejecutar el flujo completo desde cero Verificar que el dashboard funcione con datos realistas 📝 1. Actualizar DatabaseSeeder php // database/seeders/DatabaseSeeder.php <?php namespace Database \ Seeders ; use Database \ Seeders \ Demo \ DemoSeeder ; use Illuminate \ Database \ Seeder ; class DatabaseSeeder extends Seeder { public function run ( ) : void { // ============================================ // SEEDERS BASE (siempre) // ============================================ $this -> call ( [ RolePermissionSeeder :: class , PrestacionSeeder :: class , ConsultorioSeeder :: class , PacienteSeeder :: class , AntecedentesMedicosSeeder :: class , ...