45 lines
1.3 KiB
PHP
Executable File
45 lines
1.3 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Rata;
|
|
use App\Models\PianoRateizzazione;
|
|
use App\Models\RipartizioneSpese;
|
|
use App\Models\AnagraficaCondominiale;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Rata>
|
|
*/
|
|
class RataFactory extends Factory
|
|
{
|
|
protected $model = Rata::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'piano_rateizzazione_id' => function () {
|
|
return PianoRateizzazione::factory()->create()->id;
|
|
},
|
|
'ripartizione_spese_id' => function (array $attributes) {
|
|
if (!empty($attributes['piano_rateizzazione_id'])) {
|
|
$piano = PianoRateizzazione::find($attributes['piano_rateizzazione_id']);
|
|
if ($piano) {
|
|
return $piano->ripartizione_spese_id;
|
|
}
|
|
}
|
|
return RipartizioneSpese::factory()->create()->id;
|
|
},
|
|
'numero_rata' => 1,
|
|
'importo_rata' => 250.00,
|
|
'data_scadenza' => now()->addMonth(),
|
|
'stato' => 'attiva',
|
|
];
|
|
}
|
|
}
|