Skip to content

Commit

Permalink
Merge branch '1.x' into refactor-staff-model
Browse files Browse the repository at this point in the history
  • Loading branch information
adevade authored Aug 13, 2024
2 parents 8d3753b + be449b0 commit bc9908e
Show file tree
Hide file tree
Showing 93 changed files with 557 additions and 219 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"require-dev": {
"larastan/larastan": "^2.9",
"laravel/pint": "^1.16.1",
"laravel/pint": "1.17.0",
"mockery/mockery": "^1.6.9",
"orchestra/testbench": "^8.0|^9.0",
"pestphp/pest": "^2.34.7",
Expand Down
2 changes: 1 addition & 1 deletion docs/core/extending/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ $newStaticMethod = \Lunar\Models\ProductOption::getSizesStatic();
```php
namespace App\Models;

use App\Concerns\SearchableTrait
use App\Concerns\SearchableTrait;

class Product extends \Lunar\Models\Product
{
Expand Down
2 changes: 1 addition & 1 deletion docs/core/extending/payments.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CustomPayment extends AbstractPayment
/**
* {@inheritDoc}
*/
public function authorize(): PaymentAuthorize
public function authorize(): ?PaymentAuthorize
{
if (!$this->order) {
if (!$this->order = $this->cart->order) {
Expand Down
2 changes: 1 addition & 1 deletion docs/core/reference/orders.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Lunar\Models\Order
| cart_id | The related cart |
| channel_id | Which channel this was purchased through |
| status | A status that makes sense to you as the store owner |
| reference | Your stores own reference
| reference | Your store's own reference
| customer_reference | If you want customers to add their own reference, it goes here.
| sub_total | The sub total minus any discounts, excl. tax
| discount_breakdown | A json field for the discount breakdown e.g. `[{"discount_id": 1, "lines": [{"id": 1, "qty": 1}]], "total": 200}]`
Expand Down
24 changes: 24 additions & 0 deletions docs/core/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@ php artisan migrate

Lunar currently provides bug fixes and security updates for only the latest minor release, e.g. `0.8`.

## 1.0.0-alpha.34

### Medium Impact

#### Stripe Addon

The Stripe driver will now check whether an order has a value for `placed_at` against an order and if so, no further processing will take place.

Additionally, the logic in the webhook has been moved to the job queue, which is dispatched with a delay of 20 seconds, this is to allow storefronts to manually process a payment intent, in addition to the webhook, without having to worry about overlap.

The Stripe webhook ENV entry has been changed from `STRIPE_WEBHOOK_PAYMENT_INTENT` to `LUNAR_STRIPE_WEBHOOK_SECRET`.

The stripe config Lunar looks for in `config/services.php` has changed and should now look like:

```php
'stripe' => [
'key' => env('STRIPE_SECRET'),
'public_key' => env('STRIPE_PK'),
'webhooks' => [
'lunar' => env('LUNAR_STRIPE_WEBHOOK_SECRET'),
],
],
```

## 1.0.0-alpha.32

### High Impact
Expand Down
2 changes: 1 addition & 1 deletion monorepo-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
// for "merge" command
$parameters->set(Option::DATA_TO_APPEND, [
ComposerJsonSection::REQUIRE_DEV => [
'laravel/pint' => '^1.16.1',
'laravel/pint' => '1.17.0',
'mockery/mockery' => '^1.6.9',
'pestphp/pest' => '^2.34.7',
'pestphp/pest-plugin-laravel' => '^2.4',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
@endif
<x-filament-tables::cell>
<div class="fi-ta-text grid w-full gap-y-1 px-3 py-4">
<span class="fi-ta-text-item-label text-sm leading-6 text-gray-950 dark:text-white ">
<span class="fi-ta-text-item-label flex flex-col text-sm leading-6 text-gray-950 dark:text-white">
@foreach($permutation['values'] as $option => $value)
<small><strong>{{ $option }}:</strong> {{ $value }}</small>
@endforeach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function getFormActions(): array

public function form(Form $form): Form
{
return (new ManageVariantInventory())->form($form)->statePath('');
return (new ManageVariantInventory)->form($form)->statePath('');
}

public function getRelationManagers(): array
Expand Down
8 changes: 4 additions & 4 deletions packages/admin/src/LunarPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ class LunarPanelProvider extends ServiceProvider
public function register(): void
{
$this->app->scoped('lunar-panel', function (): LunarPanelManager {
return new LunarPanelManager();
return new LunarPanelManager;
});

$this->app->scoped('lunar-access-control', function (): Manifest {
return new Manifest();
return new Manifest;
});

$this->app->scoped('lunar-activity-log', function (): ActivityLogManifest {
return new ActivityLogManifest();
return new ActivityLogManifest;
});

$this->app->scoped('lunar-attribute-data', function (): AttributeData {
return new AttributeData();
return new AttributeData;
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Support/FieldTypes/Dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function getFilamentComponent(Attribute $attribute): Component
)
)
->when(filled($attribute->validation_rules), fn (Select $component) => $component->rules($attribute->validation_rules))
->required((bool) $attribute->configuration->get('required'))
->required((bool) $attribute->required)
->helperText($attribute->translate('description'));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Support/FieldTypes/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static function getFilamentComponent(Attribute $attribute): Component
{
return FileUpload::make($attribute->handle)
->when(filled($attribute->validation_rules), fn (FileUpload $component) => $component->rules($attribute->validation_rules))
->required((bool) $attribute->configuration->get('required'))
->required((bool) $attribute->required)
->helperText($attribute->translate('description'));
}
}
2 changes: 1 addition & 1 deletion packages/admin/src/Support/FieldTypes/ListField.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function getFilamentComponent(Attribute $attribute): Component
return $state;
})
->when(filled($attribute->validation_rules), fn (KeyValue $component) => $component->rules($attribute->validation_rules))
->required((bool) $attribute->configuration->get('required'))
->required((bool) $attribute->required)
->helperText($attribute->translate('description'));
}
}
2 changes: 1 addition & 1 deletion packages/admin/src/Support/FieldTypes/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function getFilamentComponent(Attribute $attribute): Component
$input = TextInput::make($attribute->handle)
->numeric()
->when(filled($attribute->validation_rules), fn (TextInput $component) => $component->rules($attribute->validation_rules))
->required((bool) $attribute->configuration->get('required'))
->required((bool) $attribute->required)
->helperText($attribute->translate('description'));

if ($min) {
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src/Support/FieldTypes/TextField.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public static function getFilamentComponent(Attribute $attribute): Component
if ($attribute->configuration->get('richtext')) {
return RichEditor::make($attribute->handle)
->when(filled($attribute->validation_rules), fn (RichEditor $component) => $component->rules($attribute->validation_rules))
->required((bool) $attribute->configuration->get('required'))
->required((bool) $attribute->required)
->helperText($attribute->translate('description'));
}

return TextInput::make($attribute->handle)
->when(filled($attribute->validation_rules), fn (TextInput $component) => $component->rules($attribute->validation_rules))
->required((bool) $attribute->configuration->get('required'))
->required((bool) $attribute->required)
->helperText($attribute->translate('description'));
}
}
2 changes: 1 addition & 1 deletion packages/admin/src/Support/FieldTypes/Toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public static function getFilamentComponent(Attribute $attribute): Component
->default(false)
->when(filled($attribute->validation_rules), fn (Toggle $component) => $component->rules($attribute->validation_rules))
->rule('boolean')
->required((bool) $attribute->configuration->get('required'));
->required((bool) $attribute->required);
}
}
2 changes: 1 addition & 1 deletion packages/admin/src/Support/FieldTypes/TranslatedText.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function getFilamentComponent(Attribute $attribute): Component
return TranslatedTextComponent::make($attribute->handle)
->optionRichtext((bool) $attribute->configuration->get('richtext'))
->when(filled($attribute->validation_rules), fn (TranslatedTextComponent $component) => $component->rules($attribute->validation_rules))
->required((bool) $attribute->configuration->get('required'))
->required((bool) $attribute->required)
->helperText($attribute->translate('description'));
}
}
2 changes: 1 addition & 1 deletion packages/admin/src/Support/FieldTypes/Vimeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function getFilamentComponent(Attribute $attribute): Component
return VimeoInput::make($attribute->handle)
->live(debounce: 200)
->when(filled($attribute->validation_rules), fn (VimeoInput $component) => $component->rules($attribute->validation_rules))
->required((bool) $attribute->configuration->get('required'))
->required((bool) $attribute->required)
->helperText(
$attribute->translate('description') ?? __('lunarpanel::components.forms.youtube.helperText')
);
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Support/FieldTypes/YouTube.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static function getFilamentComponent(Attribute $attribute): Component
return YouTubeInput::make($attribute->handle)
->live(debounce: 200)
->when(filled($attribute->validation_rules), fn (YouTubeInput $component) => $component->rules($attribute->validation_rules))
->required((bool) $attribute->configuration->get('required'))
->required((bool) $attribute->required)
->helperText(
$attribute->translate('description') ?? __('lunarpanel::components.forms.youtube.helperText')
);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/config/orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
| Order Pipelines
|--------------------------------------------------------------------------
|
| Define which pipelines should be run throughout an orders lifecycle.
| Define which pipelines should be run throughout an order's lifecycle.
| The default ones provided should suit most needs, however you are
| free to add your own as you see fit.
|
Expand Down
2 changes: 1 addition & 1 deletion packages/core/database/factories/OrderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function definition(): array
'sub_total' => $total - $taxTotal,
'discount_total' => 0,
'shipping_total' => 0,
'tax_breakdown' => new TaxBreakdown(),
'tax_breakdown' => new TaxBreakdown,
'tax_total' => $taxTotal,
'total' => $total,
'notes' => null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Lunar\Base\Migration;

return new class extends Migration
{
public function up(): void
{
Schema::table($this->prefix.'orders', function (Blueprint $table) {
$table->string('fingerprint')->nullable()->index();
});
}

public function down(): void
{
Schema::table($this->prefix.'orders', function (Blueprint $table) {
$table->dropIndex(['fingerprint']);
});
Schema::table($this->prefix.'orders', function (Blueprint $table) {
$table->dropColumn('fingerprint');
});
}
};
3 changes: 2 additions & 1 deletion packages/core/src/Actions/Carts/CreateOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ public function execute(
?int $orderIdToUpdate = null
): self {
$this->passThrough = DB::transaction(function () use ($cart, $allowMultipleOrders, $orderIdToUpdate) {
$order = $cart->draftOrder($orderIdToUpdate)->first() ?: new Order;
$order = $cart->currentDraftOrder($orderIdToUpdate) ?: new Order;

if ($cart->hasCompletedOrders() && ! $allowMultipleOrders) {
throw new DisallowMultipleCartOrdersException;
}

$order->fill([
'cart_id' => $cart->id,
'fingerprint' => $cart->fingerprint(),
]);

$order = app(Pipeline::class)
Expand Down
4 changes: 0 additions & 4 deletions packages/core/src/Actions/Carts/GenerateFingerprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@ class GenerateFingerprint
public function execute(Cart $cart)
{
$value = $cart->lines->reduce(function (?string $carry, CartLine $line) {
$meta = $line->meta?->collect()->sortKeys()->toJson();

return $carry.
$line->purchasable_type.
$line->purchasable_id.
$line->quantity.
$meta.
$line->subTotal;
});

$value .= $cart->user_id.$cart->currency_id.$cart->coupon_code;
$value .= $cart->meta?->collect()->sortKeys()->toJson();

return sha1($value);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Base/Casts/AsAttributeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AsAttributeData implements Castable
*/
public static function castUsing(array $arguments)
{
return new class() implements CastsAttributes
return new class implements CastsAttributes
{
public function get($model, $key, $value, $attributes)
{
Expand All @@ -27,7 +27,7 @@ public function get($model, $key, $value, $attributes)

$data = json_decode($attributes[$key], true);

$returnData = new Collection();
$returnData = new Collection;

foreach ($data as $key => $item) {
if (! class_exists($item['field_type'])) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Base/Casts/ShippingBreakdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ShippingBreakdown implements CastsAttributes, SerializesCastableAttributes
*/
public function get($model, $key, $value, $attributes)
{
$breakdown = new \Lunar\Base\ValueObjects\Cart\ShippingBreakdown();
$breakdown = new \Lunar\Base\ValueObjects\Cart\ShippingBreakdown;

$breakdown->items = collect(
json_decode($value, false)
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/Base/PaymentTypeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ public function setConfig(array $config): self;

/**
* Authorize the payment.
*
* @return void
*/
public function authorize(): PaymentAuthorize;
public function authorize(): ?PaymentAuthorize;

/**
* Refund a transaction for a given amount.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/FieldTypes/TranslatedText.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct($value = null)
if ($value) {
$this->setValue($value);
} else {
$this->value = new Collection();
$this->value = new Collection;
}
}

Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/LunarServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ public function register(): void
$this->registerAddonManifest();

$this->app->singleton(CartModifiers::class, function () {
return new CartModifiers();
return new CartModifiers;
});

$this->app->singleton(CartLineModifiers::class, function () {
return new CartLineModifiers();
return new CartLineModifiers;
});

$this->app->singleton(OrderModifiers::class, function () {
return new OrderModifiers();
return new OrderModifiers;
});

$this->app->singleton(CartSessionInterface::class, function ($app) {
Expand All @@ -140,7 +140,7 @@ public function register(): void
});

$this->app->singleton(ShippingModifiers::class, function ($app) {
return new ShippingModifiers();
return new ShippingModifiers;
});

$this->app->singleton(ShippingManifestInterface::class, function ($app) {
Expand Down Expand Up @@ -250,7 +250,7 @@ public function boot(): void
protected function registerAddonManifest()
{
$this->app->instance(Manifest::class, new Manifest(
new Filesystem(),
new Filesystem,
$this->app->basePath(),
$this->app->bootstrapPath().'/cache/lunar_addons.php'
));
Expand Down Expand Up @@ -340,7 +340,7 @@ protected function registerBlueprintMacros(): void
$this->foreignUuId($field_name)
->nullable($nullable)
->constrained(
(new $userModel())->getTable()
(new $userModel)->getTable()
);
} elseif ($type == 'int') {
$this->unsignedInteger($field_name)->nullable($nullable);
Expand All @@ -349,7 +349,7 @@ protected function registerBlueprintMacros(): void
$this->foreignId($field_name)
->nullable($nullable)
->constrained(
(new $userModel())->getTable()
(new $userModel)->getTable()
);
}
});
Expand Down
Loading

0 comments on commit bc9908e

Please sign in to comment.