adrema/app/Initialize/InitializeFees.php

28 lines
594 B
PHP
Raw Normal View History

2020-04-12 00:26:44 +02:00
<?php
namespace App\Initialize;
2022-02-19 18:06:07 +01:00
use App\Fee;
2022-02-12 16:16:56 +01:00
use Zoomyboy\LaravelNami\Api;
2021-11-17 23:58:28 +01:00
2020-04-12 00:26:44 +02:00
class InitializeFees {
2022-02-12 16:16:56 +01:00
private Api $api;
2020-04-12 00:26:44 +02:00
2022-02-12 16:16:56 +01:00
public function __construct(Api $api) {
2020-04-12 00:26:44 +02:00
$this->api = $api;
}
2022-02-19 18:06:07 +01:00
public function handle(): void
2022-02-12 16:16:56 +01:00
{
2022-02-19 18:06:07 +01:00
$group = $this->api->groups()->first()->id;
$this->api->feesOf($group)->each(function($fee) {
Fee::create(['nami_id' => $fee->id, 'name' => $fee->name])
2022-01-03 01:17:24 +01:00
->subscriptions()->create([
'name' => $fee->name,
'amount' => 1000,
]);
2020-04-12 00:26:44 +02:00
});
}
}