Skip to content

Calculate postage in Iran,This package supports Sefarshi and Pisthtaz drivers

Notifications You must be signed in to change notification settings

ghaninia/shipping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calculate postage in Iran

Installation

Go to the project root folder and run the following command

composer require ghaninia/shipping

If you want to make sure the system is correct, Run tests🐱‍🚀

vendor\bin\phpunit 

✔If you use package on laravel you should add below command to app.php

### config/app.php
<?php
    ....
    'providers' => [
        ...
        GhaniniaIR\Shipping\ShippingServiceProvider::class, ### ✔
    ],

Receive information of cities and provinces and their details

<?php 

use GhaniniaIR\Shipping\Core\Services\LocationService ;

### Get information on cities and provinces
(new LocationService())->list();

### Are the provinces adjacent to each other?
(new LocationService())
    ->source(State $state , City $city)
    ->destination(State $state , ?City $city)
    ->provincesNeighbors() ;

### Status of origin and destination together
(new LocationService())
    ->source(State $state , City $city)
    ->destination(State $state , ?City $city)
    ->situationStatesTogether() ; 

Calculate Post Pishtaz Tariff

<?php

use GhaniniaIR\Shipping\Drivers\PishtazDriver;
use GhaniniaIR\Shipping\Models\State ;
use GhaniniaIR\Shipping\Models\City ;

$result = (new PishtazDriver())
    ->weight(int $productWeight)
    ->cost(int $productCost)
    ->source(State $sourceState , City $sourceCity)
    ->destination(State $sourceState , ?City $sourceCity)
    ->calculate();

Calculate Post Sefareshi Tariff

<?php

use GhaniniaIR\Shipping\Drivers\SefarshiDriver;
use GhaniniaIR\Shipping\Models\State ;
use GhaniniaIR\Shipping\Models\City ;

$result = (new SefarshiDriver())
    ->weight(int $productWeight)
    ->cost(int $productCost)
    ->source(State $sourceState , City $sourceCity)
    ->destination(State $sourceState , ?City $sourceCity)
    ->calculate();

Reconnection

If you want to change the type of connection to the database, follow the code below

Laravel:
php artisan vendor:publish --tag=shipping --force

It will then be published to you in the database and configuration file