adrema/app/Initialize/InitializeFees.php

29 lines
721 B
PHP
Raw Normal View History

2020-04-12 00:26:44 +02:00
<?php
namespace App\Initialize;
2021-11-17 23:58:28 +01:00
use Zoomyboy\LaravelNami\NamiUser;
2020-04-12 00:26:44 +02:00
class InitializeFees {
private $bar;
private $api;
public function __construct($bar, $api) {
$this->bar = $bar;
$this->api = $api;
}
2021-11-17 23:58:28 +01:00
public function handle(NamiUser $user) {
$this->bar->task('Synchronisiere Beiträge', function() use ($user) {
$this->api->feesOf($user->getNamiGroupId())->each(function($fee) {
2021-07-04 12:09:30 +02:00
\App\Fee::create(['nami_id' => $fee->id, 'name' => $fee->name])
->subscriptions()->create([
'name' => $fee->name,
'amount' => 1000,
]);
2020-04-12 00:26:44 +02:00
});
});
}
}