承接 softrang/parcel-helper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

softrang/parcel-helper

最新稳定版本:v1.0.3

Composer 安装命令:

composer require softrang/parcel-helper

包简介

A small helper to place orders using API keys from env/config.

README 文档

README

A simple, developer-friendly Parcel Helper for Laravel 12+ to easily create and manage consignments with SteadFast and other supported services. created by Softrang.

Features

  • Simple API for creating parcels/orders.
  • Supports SteadFast and other courier services.
  • Automatically stores consignment details in your database.
  • Clean, professional, and Laravel-native.

Requirements

  • PHP 8.1+
  • Laravel 12+
  • Composer

Installation

Install via Composer

composer require softrang/parcel-helper

Publish the config:

php artisan vendor:publish --tag= parcel-helpar

Environment Configuration

Add your API keys to your .env file:

PACKZY_API_KEY=your_api_key
PACKZY_SECRET_KEY=your_secret_key

Usage

Sample Controller

<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Softrang\ParcelHelper\Facades\ParcelHelper;
use App\Models\Consignment;

    public function sendSteadFast(Request $request)
    {
        // Validate request
        $validated = $request->validate([
            'invoice' => 'required|string|max:50',
            'name' => 'required|string|max:255',
            'phone' => 'required|string|max:20',
            'address' => 'required|string|max:500',
            'amount' => 'required|numeric|min:0',
        ]);

        try {
            // Create order via ParcelHelper
            $response = ParcelHelper::steadfastCreateOrder([
                'invoice' => $validated['invoice'],
                'recipient_name' => $validated['name'],
                'recipient_phone' => $validated['phone'],
                'recipient_address' => $validated['address'],
                'cod_amount' => $validated['amount'],
            ]);

            if ($response['status'] === 200 && isset($response['consignment'])) {
                $c = $response['consignment'];

                // Save consignment in DB
                $consignment = Consignment::create([
                    'consignment_id' => $c['consignment_id'],
                    'invoice' => $c['invoice'],
                    'tracking_code' => $c['tracking_code'],
                    'recipient_name' => $c['recipient_name'],
                    'recipient_phone' => $c['recipient_phone'],
                    'recipient_address' => $c['recipient_address'],
                    'cod_amount' => $c['cod_amount'],
                    'status' => $c['status'],
                ]);

                return response()->json([
                    'success' => true,
                    'message' => 'Consignment created and saved successfully.',
                    'data' => $consignment,
                ], 201);
            }

            return response()->json([
                'success' => false,
                'message' => 'Failed to create consignment from API.',
                'api_response' => $response,
            ], 400);

        } catch (\Exception $e) {
            return response()->json([
                'success' => false,
                'message' => 'An error occurred while processing your request.',
                'error' => $e->getMessage(),
            ], 500);
        }
    }

Database Setup

Ensure you have a consignments table:

Schema::create('consignments', function (Blueprint $table) {
    $table->id();
    $table->string('consignment_id')->unique();
    $table->string('invoice');
    $table->string('tracking_code')->nullable();
    $table->string('recipient_name');
    $table->string('recipient_phone');
    $table->text('recipient_address');
    $table->decimal('cod_amount', 10, 2)->default(0);
    $table->string('status')->nullable();
    $table->timestamps();
});

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-06