deniztezcan/laravel-sendcloud-shipping

Laravel 对 SendCloud 物流 API 的封装

0.3.0 2021-02-16 09:10 UTC

This package is auto-updated.

Last update: 2024-09-16 17:21:23 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

这是一个基于 picqer/sendcloud-php-client 包的 Laravel 对 SendCloud 物流 API 的封装。

安装

composer require deniztezcan/laravel-sendcloud-shipping

config/app.php 文件中添加 ServiceProvider 到 providers 数组

    'providers' => [
    	//other things here

    	DenizTezcan\SendCloud\SendCloudServiceProvider::class,
    ];

将 facade 添加到 facades 数组

    'aliases' => [
    	//other things here

    	'SendCloud' => DenizTezcan\SendCloud\Facades\SendCloud::class,
    ];

最后,发布配置文件

php artisan vendor:publish --provider="DenizTezcan\SendCloud\SendCloudServiceProvider"

配置

请在 config/shipping-sendcloud.php 文件中设置您的 API: keysecret

用法

要创建和获取可打印的标签,可以使用以下代码。ordernumber 是可选的。

<?php

use DenizTezcan\SendCloud\Entities\Customer;
$customer = new Customer([
	'name' => 'John Doe',
	'company_name' => 'ACME Bank',
	'street_address' => 'Main St',
	'street_address_nr' => '123',
	'city' => 'Anytown',
	'postal_code' => '12345',
	'country' => 'DE',
]);

$parcel = SendCloud::createSingleParcel($customer, 89, 'ORDERNO');
SendCloud::getPDFFromSingleParcel($parcel);