48 lines
1.5 KiB
PHP
Executable File
48 lines
1.5 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\PianoRateizzazione;
|
|
use App\Models\RipartizioneSpese;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\PianoRateizzazione>
|
|
*/
|
|
class PianoRateizzazioneFactory extends Factory
|
|
{
|
|
protected $model = PianoRateizzazione::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'ripartizione_spese_id' => function () {
|
|
return RipartizioneSpese::factory()->create()->id;
|
|
},
|
|
'stabile_id' => function (array $attributes) {
|
|
if (!empty($attributes['ripartizione_spese_id'])) {
|
|
$ripartizione = RipartizioneSpese::find($attributes['ripartizione_spese_id']);
|
|
if ($ripartizione) {
|
|
return $ripartizione->stabile_id;
|
|
}
|
|
}
|
|
return \App\Models\Stabile::factory()->create()->id;
|
|
},
|
|
'numero_rate' => 4,
|
|
'descrizione' => $this->faker->sentence(),
|
|
'importo_totale' => 1000.00,
|
|
'data_prima_rata' => now()->addMonth(),
|
|
'frequenza' => 'mensile',
|
|
'stato' => 'attivo',
|
|
'creato_da' => function () {
|
|
return \App\Models\User::factory()->create()->id;
|
|
},
|
|
];
|
|
}
|
|
}
|