netgescon-day0/database/factories/RipartizioneSpeseFactory.php

48 lines
1.5 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\RipartizioneSpese;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\RipartizioneSpese>
*/
class RipartizioneSpeseFactory extends Factory
{
protected $model = RipartizioneSpese::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
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',
];
}
}