From 626085ed67bbc52e51344e8d7595c1a5d259b445 Mon Sep 17 00:00:00 2001 From: myrmidex Date: Sat, 5 Jul 2025 23:54:43 +0200 Subject: [PATCH] Add keywords --- app/Models/Feed.php | 1 + app/Models/FeedPlatformChannel.php | 53 ++++++++++++++ app/Models/Keyword.php | 43 ++++++++++++ app/Models/PlatformChannel.php | 1 + ...025_07_05_163010_create_keywords_table.php | 33 +++++++++ .../views/pages/routing/create.blade.php | 70 ++++++++++++++++++- 6 files changed, 198 insertions(+), 3 deletions(-) create mode 100644 app/Models/FeedPlatformChannel.php create mode 100644 app/Models/Keyword.php create mode 100644 database/migrations/2025_07_05_163010_create_keywords_table.php diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 8ca3368..2b071d6 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -81,6 +81,7 @@ public function getStatusAttribute(): string public function channels(): BelongsToMany { return $this->belongsToMany(PlatformChannel::class, 'feed_platform_channels') + ->using(FeedPlatformChannel::class) ->withPivot(['is_active', 'priority', 'filters']) ->withTimestamps(); } diff --git a/app/Models/FeedPlatformChannel.php b/app/Models/FeedPlatformChannel.php new file mode 100644 index 0000000..a12c097 --- /dev/null +++ b/app/Models/FeedPlatformChannel.php @@ -0,0 +1,53 @@ + 'boolean', + 'filters' => 'array' + ]; + + public function feed(): BelongsTo + { + return $this->belongsTo(Feed::class); + } + + public function platformChannel(): BelongsTo + { + return $this->belongsTo(PlatformChannel::class); + } + + public function keywords(): HasMany + { + return $this->hasMany(Keyword::class, 'feed_id', 'feed_id') + ->where('platform_channel_id', $this->platform_channel_id); + } +} \ No newline at end of file diff --git a/app/Models/Keyword.php b/app/Models/Keyword.php new file mode 100644 index 0000000..153e69c --- /dev/null +++ b/app/Models/Keyword.php @@ -0,0 +1,43 @@ + 'boolean' + ]; + + public function feed(): BelongsTo + { + return $this->belongsTo(Feed::class); + } + + public function platformChannel(): BelongsTo + { + return $this->belongsTo(PlatformChannel::class); + } + +} diff --git a/app/Models/PlatformChannel.php b/app/Models/PlatformChannel.php index b975f72..4e1bd58 100644 --- a/app/Models/PlatformChannel.php +++ b/app/Models/PlatformChannel.php @@ -58,6 +58,7 @@ public function getFullNameAttribute(): string public function feeds(): BelongsToMany { return $this->belongsToMany(Feed::class, 'feed_platform_channels') + ->using(FeedPlatformChannel::class) ->withPivot(['is_active', 'priority', 'filters']) ->withTimestamps(); } diff --git a/database/migrations/2025_07_05_163010_create_keywords_table.php b/database/migrations/2025_07_05_163010_create_keywords_table.php new file mode 100644 index 0000000..8f9889a --- /dev/null +++ b/database/migrations/2025_07_05_163010_create_keywords_table.php @@ -0,0 +1,33 @@ +id(); + $table->foreignId('feed_id')->constrained()->onDelete('cascade'); + $table->foreignId('platform_channel_id')->constrained()->onDelete('cascade'); + $table->string('keyword'); + $table->boolean('is_active')->default(true); + $table->timestamps(); + + $table->unique(['feed_id', 'platform_channel_id', 'keyword']); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('keywords'); + } +}; diff --git a/resources/views/pages/routing/create.blade.php b/resources/views/pages/routing/create.blade.php index f415e51..9234e02 100644 --- a/resources/views/pages/routing/create.blade.php +++ b/resources/views/pages/routing/create.blade.php @@ -75,13 +75,43 @@ class="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-indigo-
- + +
+
+ + +
+
+ +

Articles will be filtered to only include content matching these keywords

+ @error('keywords') +

{{ $message }}

+ @enderror + @error('keywords.*') +

{{ $message }}

+ @enderror +
+ +
+ -

JSON format for content filtering rules

+ placeholder='{"exclude_keywords": ["sports"], "min_length": 100}'>{{ old('filters') }} +

JSON format for additional content filtering rules

@error('filters')

{{ $message }}

@enderror @@ -124,4 +154,38 @@ class="mt-1 block w-full border-gray-300 rounded-md shadow-sm focus:ring-indigo- @endif
+ + @endsection \ No newline at end of file