Skip to content

Commit f161dd4

Browse files
author
Sebastian Fix
committed
wip
1 parent 45c7ddb commit f161dd4

9 files changed

Lines changed: 142 additions & 52 deletions

File tree

app/Models/Product.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Traits\HasLocalizedRouteBinding;
88
use Illuminate\Database\Eloquent\Factories\HasFactory;
99
use Illuminate\Database\Eloquent\Model;
10+
use Illuminate\Database\Eloquent\Relations\HasMany;
1011

1112
class Product extends Model
1213
{
@@ -24,4 +25,9 @@ public function getRouteKeyName(): string
2425
{
2526
return 'slug';
2627
}
28+
29+
public function productModules(): HasMany
30+
{
31+
return $this->hasMany(ProductModule::class);
32+
}
2733
}

app/Models/ProductModule.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use App\Enums\LocaleEnum;
6+
use App\Traits\HasLocalizedReferences;
7+
use App\Traits\HasLocalizedRouteBinding;
8+
use Illuminate\Database\Eloquent\Factories\HasFactory;
9+
use Illuminate\Database\Eloquent\Model;
10+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
11+
12+
class ProductModule extends Model
13+
{
14+
use HasFactory;
15+
use HasLocalizedReferences;
16+
use HasLocalizedRouteBinding;
17+
18+
protected $casts = [
19+
'published' => 'boolean',
20+
'locale' => LocaleEnum::class,
21+
'tags' => 'json',
22+
];
23+
24+
public function getRouteKeyName(): string
25+
{
26+
return 'slug';
27+
}
28+
29+
public function product(): BelongsTo
30+
{
31+
return $this->belongsTo(Product::class);
32+
}
33+
}

composer.lock

Lines changed: 43 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
7+
/**
8+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ProductModule>
9+
*/
10+
class ProductModuleFactory extends Factory
11+
{
12+
/**
13+
* Define the model's default state.
14+
*
15+
* @return array<string, mixed>
16+
*/
17+
public function definition(): array
18+
{
19+
return [
20+
//
21+
];
22+
}
23+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('product_modules', function (Blueprint $table) {
15+
$table->id();
16+
$table->timestamps();
17+
});
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*/
23+
public function down(): void
24+
{
25+
Schema::dropIfExists('product_modules');
26+
}
27+
};

database/seeders/ServicesTableSeeder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ public function run(): void
2020
LocaleEnum::DE->value => [
2121
'name' => 'DocuWare',
2222
'teaser' => 'Intelligentes Dokumentenmanagement mit DocuWare',
23-
'tags' => ['DMS/ECM'],
23+
'tags' => ['DMS/ECM', 'DocuWare'],
2424
'content' => file_get_contents(database_path('files/services/de_CH/docuware.md')),
2525
'image' => 'https://res.cloudinary.com/codebar/image/upload/c_scale,dpr_2.0,f_auto,q_auto,w_1200/www-paperflakes-ch/seo/seo_paperflakes.webp',
2626
],
2727
LocaleEnum::EN->value => [
2828
'name' => 'DocuWare',
2929
'teaser' => 'Smarter Document Management with DocuWare',
30-
'tags' => ['DMS/ECM'],
30+
'tags' => ['DMS/ECM', 'DocuWare'],
3131
'content' => file_get_contents(database_path('files/services/en_CH/docuware.md')),
3232
'image' => 'https://res.cloudinary.com/codebar/image/upload/c_scale,dpr_2.0,f_auto,q_auto,w_1200/www-paperflakes-ch/seo/seo_paperflakes.webp',
3333
],

resources/views/app/products/show.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x-content :content="$content"/>
88
</x-section>
99

10-
@if(in_array('DocuWare', $tags))
10+
@if(collect(['DMS/ECM', 'DocuWare'])->diff($tags)->isEmpty())
1111
<x-docuware-showme/>
1212
@endif
1313

0 commit comments

Comments
 (0)