first upload all files

This commit is contained in:
NW
2023-06-11 13:14:03 +01:00
parent f14dbc52b5
commit c08b36d1b6
1705 changed files with 106852 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<?php
namespace Modules\Shipping\Facades;
use Illuminate\Support\Facades\Facade;
/**
* @method static \Illuminate\Support\Collection available()
* @method static \Illuminate\Support\Collection all()
* @method static array names()
* @method static object get(string $name)
* @method static \Modules\Shipping\ShippingMethodManager register(string $name, callable|object $driver)
* @method static int count()
* @method static bool isEmpty()
* @method static bool isNotEmpty()
*
* @see \Modules\Shipping\ShippingMethodManager
*/
class ShippingMethod extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return \Modules\Shipping\ShippingMethodManager::class;
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Modules\Shipping;
use Modules\Support\Money;
use Modules\Cart\Facades\Cart;
class Method
{
public $name;
public $label;
public $cost;
public function __construct($name, $label, $cost)
{
$this->name = $name;
$this->label = $label;
$this->cost = Money::inDefaultCurrency($cost);
}
public function available()
{
if ($this->name !== 'free_shipping') {
return true;
}
return $this->freeShippingMethodIsAvailable();
}
private function freeShippingMethodIsAvailable()
{
$minimumAmount = Money::inDefaultCurrency(setting('free_shipping_min_amount'));
return Cart::subTotal()->greaterThanOrEqual($minimumAmount);
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace Modules\Shipping\Providers;
use Modules\Shipping\Method;
use Illuminate\Support\ServiceProvider;
use Modules\Shipping\Facades\ShippingMethod;
class ShippingServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
if (! config('app.installed')) {
return;
}
$this->registerFreeShipping();
$this->registerLocalPickup();
$this->registerFlatRate();
}
private function registerFreeShipping()
{
if (! setting('free_shipping_enabled')) {
return;
}
ShippingMethod::register('free_shipping', function () {
return new Method('free_shipping', setting('free_shipping_label'), 0);
});
}
private function registerLocalPickup()
{
if (! setting('local_pickup_enabled')) {
return;
}
ShippingMethod::register('local_pickup', function () {
return new Method('local_pickup', setting('local_pickup_label'), setting('local_pickup_cost'));
});
}
private function registerFlatRate()
{
if (! setting('flat_rate_enabled')) {
return;
}
ShippingMethod::register('flat_rate', function () {
return new Method('flat_rate', setting('flat_rate_label'), setting('flat_rate_cost'));
});
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Modules\Shipping;
use Modules\Support\Manager;
class ShippingMethodManager extends Manager
{
public function available()
{
return $this->all()->filter->available();
}
}

View File

@@ -0,0 +1,27 @@
{
"name": "fleetcart/shipping",
"description": "The FleetCart Shipping Module.",
"authors": [
{
"name": "Envay Soft",
"email": "envaysoft@gmail.com"
}
],
"require": {
"php": "^8.0.2"
},
"autoload": {
"psr-4": {
"Modules\\Shipping\\": ""
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev"
}

View File

@@ -0,0 +1,9 @@
{
"name": "Shipping",
"alias": "shipping",
"description": "The FleetCart Shipping Module.",
"priority": 100,
"providers": [
"Modules\\Shipping\\Providers\\ShippingServiceProvider"
]
}