5 Commits

5 changed files with 269 additions and 2 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## [0.2.0] - 2026-07-09
## [0.1.0] - 2026-07-09
### Added
- **Shipping**: registered Lunar's `lunarphp/table-rate-shipping` plugin (`ShippingPlugin`) directly on `CorePlugin`, so table-rate shipping is available to every consumer app without per-app wiring.
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "boboko/core",
"description": "Core module — authentication and shared panel behaviour",
"type": "library",
"version": "0.2.0",
"version": "0.1.2",
"autoload": {
"psr-4": {
"Modules\\Core\\": "src/"
+249
View File
@@ -0,0 +1,249 @@
<?php
namespace Modules\Core\Command;
use Illuminate\Console\Command;
use Lunar\Facades\DB;
use Lunar\FieldTypes\TranslatedText;
use Lunar\Models\Attribute;
use Lunar\Models\AttributeGroup;
use Lunar\Models\Channel;
use Lunar\Models\Collection;
use Lunar\Models\CollectionGroup;
use Lunar\Models\Country;
use Lunar\Models\Currency;
use Lunar\Models\CustomerGroup;
use Lunar\Models\Language;
use Lunar\Models\Product;
use Lunar\Models\ProductType;
use Lunar\Models\TaxClass;
use Lunar\Models\TaxZone;
/**
* Overrides Lunar's own lunar:install to skip the interactive prompts (migrate
* confirmation, admin creation, GitHub star), so it's safe to run unattended from
* the entrypoint on every boot. Migrations already run as a separate, earlier
* entrypoint step; the admin user is created manually.
*/
class InstallLunarCommand extends Command
{
protected $signature = 'lunar:install';
protected $description = 'Seed the default Lunar store data (countries, channel, currency, tax zone, attributes, product type)';
public function handle(): void
{
$this->components->info('Seeding default Lunar store data...');
if (! Country::count()) {
$this->components->info('Importing countries');
$this->call('lunar:import:address-data');
}
DB::transaction(function () {
if (! Channel::whereDefault(true)->exists()) {
$this->components->info('Setting up default channel');
Channel::create([
'name' => 'Webstore',
'handle' => 'webstore',
'default' => true,
'url' => 'http://localhost',
]);
}
if (! Language::count()) {
$this->components->info('Adding default language');
Language::create([
'code' => 'en',
'name' => 'English',
'default' => true,
]);
}
if (! Currency::whereDefault(true)->exists()) {
$this->components->info('Adding a default currency (USD)');
Currency::create([
'code' => 'USD',
'name' => 'US Dollar',
'exchange_rate' => 1,
'decimal_places' => 2,
'default' => true,
'enabled' => true,
]);
}
if (! CustomerGroup::whereDefault(true)->exists()) {
$this->components->info('Adding a default customer group.');
CustomerGroup::create([
'name' => 'Retail',
'handle' => 'retail',
'default' => true,
]);
}
if (! CollectionGroup::count()) {
$this->components->info('Adding an initial collection group');
CollectionGroup::create([
'name' => 'Main',
'handle' => 'main',
]);
}
if (! TaxClass::count()) {
$this->components->info('Adding a default tax class.');
TaxClass::create([
'name' => 'Default Tax Class',
'default' => true,
]);
}
if (! TaxZone::count()) {
$this->components->info('Adding a default tax zone.');
$taxZone = TaxZone::create([
'name' => 'Default Tax Zone',
'zone_type' => 'country',
'price_display' => 'tax_exclusive',
'default' => true,
'active' => true,
]);
$taxZone->countries()->createMany(
Country::get()->map(fn ($country) => [
'country_id' => $country->id,
])
);
}
if (! Attribute::count()) {
$this->components->info('Setting up initial attributes');
$group = AttributeGroup::create([
'attributable_type' => Product::morphName(),
'name' => collect([
'en' => 'Details',
]),
'handle' => 'details',
'position' => 1,
]);
$collectionGroup = AttributeGroup::create([
'attributable_type' => Collection::morphName(),
'name' => collect([
'en' => 'Details',
]),
'handle' => 'collection_details',
'position' => 1,
]);
Attribute::create([
'attribute_type' => 'product',
'attribute_group_id' => $group->id,
'position' => 1,
'name' => [
'en' => 'Name',
],
'handle' => 'name',
'section' => 'main',
'type' => TranslatedText::class,
'required' => true,
'default_value' => null,
'configuration' => [
'richtext' => false,
],
'system' => true,
'description' => [
'en' => '',
],
]);
Attribute::create([
'attribute_type' => 'collection',
'attribute_group_id' => $collectionGroup->id,
'position' => 1,
'name' => [
'en' => 'Name',
],
'handle' => 'name',
'section' => 'main',
'type' => TranslatedText::class,
'required' => true,
'default_value' => null,
'configuration' => [
'richtext' => false,
],
'system' => true,
'description' => [
'en' => '',
],
]);
Attribute::create([
'attribute_type' => 'product',
'attribute_group_id' => $group->id,
'position' => 2,
'name' => [
'en' => 'Description',
],
'handle' => 'description',
'section' => 'main',
'type' => TranslatedText::class,
'required' => false,
'default_value' => null,
'configuration' => [
'richtext' => true,
],
'system' => false,
'description' => [
'en' => '',
],
]);
Attribute::create([
'attribute_type' => 'collection',
'attribute_group_id' => $collectionGroup->id,
'position' => 2,
'name' => [
'en' => 'Description',
],
'handle' => 'description',
'section' => 'main',
'type' => TranslatedText::class,
'required' => false,
'default_value' => null,
'configuration' => [
'richtext' => true,
],
'system' => false,
'description' => [
'en' => '',
],
]);
}
if (! ProductType::count()) {
$this->components->info('Adding a product type.');
$type = ProductType::create([
'name' => 'Stock',
]);
$type->mappedAttributes()->attach(
Attribute::whereAttributeType(
Product::morphName()
)->get()->pluck('id')
);
}
});
$this->components->info('Publishing Filament assets');
$this->call('filament:assets');
$this->components->info('Lunar default data seeded.');
}
}
@@ -6,8 +6,10 @@ use Illuminate\Support\Facades\Log;
use Lunar\Models\Collection;
use Lunar\Models\CollectionGroup;
use Lunar\Models\Currency;
use Lunar\Models\Language;
use Lunar\Models\Product;
use Lunar\Models\ProductVariant;
use Lunar\Models\Url;
use Modules\Core\MigrateImport\ImportSpec;
use Modules\Core\MigrateImport\Importer;
use Modules\Core\MigrateImport\Models\ImportMapping;
@@ -91,6 +93,18 @@ class ShopifyExportImporter implements Importer
ImportMapping::record(self::SOURCE, 'product', $group->handle, $product);
Url::updateOrCreate(
[
'element_type' => $product->getMorphClass(),
'element_id' => $product->id,
'language_id' => Language::getDefault()->id,
],
[
'slug' => $group->handle,
'default' => true,
],
);
$this->tagResolver->resolve($product, $row['Tags'] ?? null);
$this->collectionResolver->resolve($product, $collectionGroup, $row['Product Category'] ?? null);
+4
View File
@@ -8,6 +8,7 @@ use Modules\Core\Command\AnonymizeCommand;
use Modules\Core\Command\ExportCleanupCommand;
use Modules\Core\Command\ExportCommand;
use Modules\Core\Command\ImportCommand;
use Modules\Core\Command\InstallLunarCommand;
use Modules\Core\Command\MigrateImportCommand;
class CoreServiceProvider extends ServiceProvider
@@ -34,6 +35,9 @@ class CoreServiceProvider extends ServiceProvider
if ($this->app->runningInConsole()) {
$this->commands([AnonymizeCommand::class, ExportCommand::class, ExportCleanupCommand::class, ImportCommand::class, MigrateImportCommand::class]);
//Overriding lunar:install
$this->app->booted(fn () => $this->commands([InstallLunarCommand::class]));
}
}
}