<?php

namespace Database\Seeders;

use App\Models\OrderManagement\BillingDesk;
use App\Models\UserManagement\Admin;
use Illuminate\Database\Seeder;;

class PointOfSalesSeeder extends Seeder{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run(){

      BillingDesk::factory(5)->create(); // Creer 5 PDV

      $admins =   Admin::superAdmins()->get();

      if(filled($admins)){
          //$cashiers = PointOfSale::all()->pluck("id")->random(rand(1,5));
          $cashiers = BillingDesk::all()->pluck("id")->toArray();

          $admins->map->sync($cashiers);

//          foreach ($admins as $admin) {
//              $admin->billingDesks()->sync($cashiers);
//          }

      }
        echo __("5 Point Of Sales created and sync with :count managers\n",['count' =>format_amount(count($admins))]);
    }
}
