Skip to content

Commit ec5376c

Browse files
authored
Merge branch 'main' into f4
2 parents f0c2f6d + d56bac8 commit ec5376c

59 files changed

Lines changed: 5005 additions & 13 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
"datalinx/php-utils": "^2.5",
4747
"eclipsephp/common": "dev-main",
4848
"filament/filament": "^4.0",
49+
"filament/spatie-laravel-translatable-plugin": "^3.3",
50+
"spatie/image": "^3.8",
51+
"solution-forest/filament-tree": "^2.1",
4952
"spatie/laravel-package-tools": "^1.19"
5053
},
5154
"require-dev": {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Eclipse\Cms\Factories;
4+
5+
use Eclipse\Cms\Models\Banner;
6+
use Illuminate\Database\Eloquent\Factories\Factory;
7+
8+
class BannerFactory extends Factory
9+
{
10+
protected $model = Banner::class;
11+
12+
public function definition(): array
13+
{
14+
$names = [
15+
'en' => ['Summer Sale', 'Winter Sale', 'Special Offer', 'New Arrivals', 'Featured Deal'],
16+
'sl' => ['Poletna Razprodaja', 'Zimska Razprodaja', 'Posebna Ponudba', 'Nove Stvari', 'Izpostavljena Ponudba'],
17+
];
18+
19+
$nameIndex = $this->faker->numberBetween(0, count($names['en']) - 1);
20+
21+
return [
22+
'name' => [
23+
'en' => $names['en'][$nameIndex],
24+
'sl' => $names['sl'][$nameIndex],
25+
],
26+
'link' => 'https://example.com/'.$this->faker->slug(2),
27+
'is_active' => $this->faker->boolean(80),
28+
'new_tab' => $this->faker->boolean(30),
29+
'sort' => $this->faker->numberBetween(1, 10),
30+
];
31+
}
32+
33+
public function active(): static
34+
{
35+
return $this->state(fn (array $attributes): array => [
36+
'is_active' => true,
37+
]);
38+
}
39+
40+
public function inactive(): static
41+
{
42+
return $this->state(fn (array $attributes): array => [
43+
'is_active' => false,
44+
]);
45+
}
46+
47+
public function newTab(): static
48+
{
49+
return $this->state(fn (array $attributes): array => [
50+
'new_tab' => true,
51+
]);
52+
}
53+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
namespace Eclipse\Cms\Factories;
4+
5+
use Eclipse\Cms\Models\Banner\Image;
6+
use Illuminate\Database\Eloquent\Factories\Factory;
7+
8+
class BannerImageFactory extends Factory
9+
{
10+
protected $model = Image::class;
11+
12+
public function definition(): array
13+
{
14+
$sampleImages = [
15+
'banners/summer-sale-desktop.jpg',
16+
'banners/winter-collection-mobile.jpg',
17+
'banners/spring-deals-tablet.jpg',
18+
'banners/black-friday-hero.jpg',
19+
'banners/new-arrivals-sidebar.jpg',
20+
'banners/limited-offer-footer.jpg',
21+
'banners/featured-product-square.jpg',
22+
'banners/special-promo-wide.jpg',
23+
'banners/holiday-sale-banner.jpg',
24+
'banners/end-season-deals.jpg',
25+
];
26+
27+
return [
28+
'file' => $this->faker->randomElement($sampleImages),
29+
'image_width' => $this->faker->randomElement([400, 800, 1200, 1920]),
30+
'image_height' => $this->faker->randomElement([200, 400, 600, 800]),
31+
'is_hidpi' => $this->faker->boolean(30),
32+
];
33+
}
34+
35+
public function desktop(): static
36+
{
37+
return $this->state(fn (array $attributes): array => [
38+
'file' => 'banners/desktop-'.$this->faker->slug().'.jpg',
39+
'image_width' => 1920,
40+
'image_height' => 600,
41+
'is_hidpi' => false,
42+
]);
43+
}
44+
45+
public function mobile(): static
46+
{
47+
return $this->state(fn (array $attributes): array => [
48+
'file' => 'banners/mobile-'.$this->faker->slug().'.jpg',
49+
'image_width' => 800,
50+
'image_height' => 400,
51+
'is_hidpi' => true,
52+
]);
53+
}
54+
55+
public function tablet(): static
56+
{
57+
return $this->state(fn (array $attributes): array => [
58+
'file' => 'banners/tablet-'.$this->faker->slug().'.jpg',
59+
'image_width' => 1024,
60+
'image_height' => 500,
61+
'is_hidpi' => false,
62+
]);
63+
}
64+
65+
public function square(): static
66+
{
67+
return $this->state(fn (array $attributes): array => [
68+
'file' => 'banners/square-'.$this->faker->slug().'.jpg',
69+
'image_width' => 400,
70+
'image_height' => 400,
71+
'is_hidpi' => false,
72+
]);
73+
}
74+
75+
public function hidpi(): static
76+
{
77+
return $this->state(fn (array $attributes): array => [
78+
'is_hidpi' => true,
79+
'image_width' => $attributes['image_width'] * 2,
80+
'image_height' => $attributes['image_height'] * 2,
81+
]);
82+
}
83+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace Eclipse\Cms\Factories;
4+
5+
use Eclipse\Cms\Models\Banner\ImageType;
6+
use Illuminate\Database\Eloquent\Factories\Factory;
7+
8+
class BannerImageTypeFactory extends Factory
9+
{
10+
protected $model = ImageType::class;
11+
12+
public function definition(): array
13+
{
14+
return [
15+
'name' => [
16+
'en' => 'Desktop',
17+
'sl' => 'Namizje',
18+
],
19+
'code' => 'desktop',
20+
'image_width' => 1200,
21+
'image_height' => 400,
22+
'is_hidpi' => false,
23+
];
24+
}
25+
26+
public function desktop(): static
27+
{
28+
return $this->state(fn (array $attributes) => [
29+
'name' => [
30+
'en' => 'Desktop',
31+
'sl' => 'Namizje',
32+
],
33+
'code' => 'desktop',
34+
'image_width' => 1200,
35+
'image_height' => 400,
36+
'is_hidpi' => false,
37+
]);
38+
}
39+
40+
public function mobile(): static
41+
{
42+
return $this->state(fn (array $attributes) => [
43+
'name' => [
44+
'en' => 'Mobile',
45+
'sl' => 'Mobilni',
46+
],
47+
'code' => 'mobile',
48+
'image_width' => 800,
49+
'image_height' => 400,
50+
'is_hidpi' => true,
51+
]);
52+
}
53+
54+
public function hidpi(): static
55+
{
56+
return $this->state(fn (array $attributes) => [
57+
'is_hidpi' => true,
58+
]);
59+
}
60+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Eclipse\Cms\Factories;
4+
5+
use Eclipse\Cms\Models\Banner\Position;
6+
use Illuminate\Database\Eloquent\Factories\Factory;
7+
8+
class BannerPositionFactory extends Factory
9+
{
10+
protected $model = Position::class;
11+
12+
public function definition(): array
13+
{
14+
return [
15+
'name' => [
16+
'en' => 'Website Banners',
17+
'sl' => 'Spletni Bannerji',
18+
],
19+
'code' => 'website',
20+
];
21+
}
22+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::create('cms_menus', function (Blueprint $table) {
12+
$table->id();
13+
14+
if (config('eclipse-cms.tenancy.enabled')) {
15+
$tenantClass = config('eclipse-cms.tenancy.model');
16+
/** @var \Illuminate\Database\Eloquent\Model $tenant */
17+
$tenant = new $tenantClass;
18+
$table->foreignId(config('eclipse-cms.tenancy.foreign_key'))
19+
->constrained($tenant->getTable(), $tenant->getKeyName())
20+
->cascadeOnUpdate()
21+
->cascadeOnDelete();
22+
}
23+
24+
$table->string('title');
25+
$table->boolean('is_active')->default(true);
26+
$table->string('code')->nullable();
27+
$table->timestamps();
28+
$table->softDeletes();
29+
});
30+
}
31+
32+
public function down(): void
33+
{
34+
Schema::dropIfExists('cms_menus');
35+
}
36+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::create('cms_menu_items', function (Blueprint $table) {
12+
$table->id();
13+
$table->string('label');
14+
$table->foreignId('menu_id')
15+
->constrained('cms_menus', 'id')
16+
->cascadeOnUpdate()
17+
->cascadeOnDelete();
18+
$table->integer('parent_id')->default(-1);
19+
$table->string('type');
20+
$table->string('linkable_class')->nullable();
21+
$table->string('linkable_id')->nullable();
22+
$table->text('custom_url')->nullable();
23+
$table->boolean('new_tab')->default(false);
24+
$table->boolean('is_active')->default(true);
25+
$table->integer('sort')->default(0);
26+
$table->timestamps();
27+
$table->softDeletes();
28+
});
29+
}
30+
31+
public function down(): void
32+
{
33+
Schema::dropIfExists('cms_menu_items');
34+
}
35+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::create('cms_banner_positions', function (Blueprint $table) {
12+
$table->id();
13+
14+
if (config('eclipse-cms.tenancy.enabled')) {
15+
$tenantClass = config('eclipse-cms.tenancy.model');
16+
/** @var \Illuminate\Database\Eloquent\Model $tenant */
17+
$tenant = new $tenantClass;
18+
$table->foreignId(config('eclipse-cms.tenancy.foreign_key'))
19+
->constrained($tenant->getTable(), $tenant->getKeyName())
20+
->cascadeOnUpdate()
21+
->cascadeOnDelete();
22+
}
23+
24+
$table->string('name');
25+
$table->string('code', 20)->nullable();
26+
$table->timestamps();
27+
$table->softDeletes();
28+
});
29+
}
30+
31+
public function down(): void
32+
{
33+
Schema::dropIfExists('cms_banner_positions');
34+
}
35+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::create('cms_banner_image_types', function (Blueprint $table) {
12+
$table->id();
13+
$table->foreignId('position_id');
14+
$table->string('name');
15+
$table->string('code')->nullable();
16+
$table->smallInteger('image_width')->nullable();
17+
$table->smallInteger('image_height')->nullable();
18+
$table->boolean('is_hidpi');
19+
});
20+
}
21+
22+
public function down(): void
23+
{
24+
Schema::dropIfExists('cms_banner_image_types');
25+
}
26+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::create('cms_banners', function (Blueprint $table) {
12+
$table->id();
13+
$table->foreignId('position_id')
14+
->constrained('cms_banner_positions', 'id')
15+
->cascadeOnUpdate()
16+
->cascadeOnDelete();
17+
$table->string('name');
18+
$table->string('link')->nullable();
19+
$table->boolean('is_active')->default(false);
20+
$table->boolean('new_tab')->default(false);
21+
$table->unsignedTinyInteger('sort')->default(0);
22+
$table->timestamps();
23+
$table->softDeletes();
24+
});
25+
}
26+
27+
public function down(): void
28+
{
29+
Schema::dropIfExists('cms_banners');
30+
}
31+
};

0 commit comments

Comments
 (0)