<?php

namespace Database\Seeders;

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

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

      Warehouse::factory(2)->isStore()->create(); // Creer 5 Entrepots => Magasins
      Warehouse::factory(5)->isPointOfSales()->create(); // 5 Entrepots => Magasins

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

      if(filled($admins)){
          $point_of_sales = Warehouse::pointofSales()->get()->pluck("id")->toArray();
          $stores = Warehouse::stores()->get()->pluck("id")->toArray();
          $warehouses = array_merge($point_of_sales,$stores);

          foreach ($admins as $admin) {
              $admin->warehouses()->sync($warehouses);
          }
      }
        echo __("2 Warehouses => Stores created and sync with :count managers\n",['count' =>format_amount(count($admins))]);
        echo __("5 Warehouses => Point Of Sales created and sync with :count managers\n",['count' =>format_amount(count($admins))]);
    }
}
