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);
}
}