HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/app/ArtisanCommands/SendcloudShipmentMethods.php
<?php

namespace App\ArtisanCommands;

use App\Shipments\ProviderAdapters\Sendcloud as SendcloudAdapter;
use Illuminate\Console\Command;
use Illuminate\Support\Arr;
use function Clue\StreamFilter\fun;

class SendcloudShipmentMethods extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'sendcloud:shipment_methods';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Shows a list of all possible shipment methods';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $adapter = new SendcloudAdapter();
        $shippingMethods = $adapter->shippingMethods();
        $shippingMethodRows = collect($shippingMethods)->map(function ($shippingMethods) {
            $shippingMethods['countries'] = collect($shippingMethods['countries'])->map(function($country) {
               return $country['name'].' => '.$country['price'];
            })->join(PHP_EOL);

            return $shippingMethods;
        });


        $this->line('Sendcloud shipment methods: ');
        $this->line('');
        $this->table(['id', 'name', 'carrier', 'min weight', 'max weight', 'service point input', 'price', 'countries'], $shippingMethodRows);
    }
}