Add event for mass store
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
cc650ebf45
commit
ebf856252c
|
@ -2,12 +2,14 @@
|
||||||
|
|
||||||
namespace App\Invoice\Actions;
|
namespace App\Invoice\Actions;
|
||||||
|
|
||||||
|
use App\Invoice\Events\InvoicesMassStored;
|
||||||
use App\Invoice\Models\Invoice;
|
use App\Invoice\Models\Invoice;
|
||||||
use App\Lib\JobMiddleware\JobChannels;
|
use App\Lib\JobMiddleware\JobChannels;
|
||||||
use App\Lib\JobMiddleware\WithJobState;
|
use App\Lib\JobMiddleware\WithJobState;
|
||||||
use App\Lib\Queue\TracksJob;
|
use App\Lib\Queue\TracksJob;
|
||||||
use App\Member\Member;
|
use App\Member\Member;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Lorisleiva\Actions\ActionRequest;
|
use Lorisleiva\Actions\ActionRequest;
|
||||||
use Lorisleiva\Actions\Concerns\AsAction;
|
use Lorisleiva\Actions\Concerns\AsAction;
|
||||||
|
|
||||||
|
@ -28,6 +30,9 @@ class MassStoreAction
|
||||||
|
|
||||||
public function handle(int $year): void
|
public function handle(int $year): void
|
||||||
{
|
{
|
||||||
|
/** @var Collection<int, Invoice> */
|
||||||
|
$invoices = collect([]);
|
||||||
|
|
||||||
$memberGroup = Member::payable()->get()
|
$memberGroup = Member::payable()->get()
|
||||||
->groupBy(fn ($member) => "{$member->bill_kind->value}{$member->lastname}{$member->address}{$member->zip}{$member->location}");
|
->groupBy(fn ($member) => "{$member->bill_kind->value}{$member->lastname}{$member->address}{$member->zip}{$member->location}");
|
||||||
foreach ($memberGroup as $members) {
|
foreach ($memberGroup as $members) {
|
||||||
|
@ -42,7 +47,11 @@ class MassStoreAction
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$invoices->push($invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event(new InvoicesMassStored($year, $invoices));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function asController(ActionRequest $request): JsonResponse
|
public function asController(ActionRequest $request): JsonResponse
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Invoice\Events;
|
||||||
|
|
||||||
|
use App\Invoice\Models\Invoice;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
class InvoicesMassStored
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Collection<int, Invoice> $invoices
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(public int $year, public Collection $invoices)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue