wip(Member & memberships sections)
All checks were successful
Deploy Roxane to Preprod / deploy (push) Successful in 1m29s

This commit is contained in:
2026-02-03 10:53:23 +01:00
parent e78f86d125
commit f39651748d
35 changed files with 1333 additions and 981 deletions

View File

@@ -0,0 +1,49 @@
<?php
namespace App\Console\Commands;
use App\Models\Member;
use App\Models\Service;
use Illuminate\Console\Command;
use function Laravel\Prompts\progress;
class SyncServicesMembers extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'memberships:sync-services';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Temporary command to sync services members';
/**
* Execute the console command.
*/
public function handle(): void
{
// Tous les membres ayant une adhésion en court ont les services activés
$this->info('Syncing services members...');
$members = Member::whereIn('status', ['valid', 'pending'] )->get();
$progressBar = progress(label: 'Syncing services members', steps: $members->count());
$services = Service::all();
foreach ($members as $member) {
$membership = $member->memberships()->where('status', 'active')->first();
$membership->services()->attach($services);
$progressBar->advance();
}
$progressBar->finish();
$this->info('Syncing services members done');
}
}