*/ class RipartizioneSpeseFactory extends Factory { protected $model = RipartizioneSpese::class; /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'stabile_id' => function () { return \App\Models\Stabile::factory()->create()->id; }, 'voce_spesa_id' => function (array $attributes) { $stabileId = $attributes['stabile_id'] ?? \App\Models\Stabile::factory()->create()->id; return \App\Models\VoceSpesa::factory()->create([ 'stabile_id' => $stabileId, ])->id; }, 'tabella_millesimale_id' => function (array $attributes) { $stabileId = $attributes['stabile_id'] ?? \App\Models\Stabile::factory()->create()->id; return \App\Models\TabellaMillesimale::factory()->create([ 'stabile_id' => $stabileId, ])->id; }, 'creato_da' => function () { return \App\Models\User::factory()->create()->id; }, 'importo_totale' => 1000.00, 'data_ripartizione' => now(), 'stato' => 'bozza', 'tipo_ripartizione' => 'millesimale', ]; } }