From 3d899034f97ee8e8c211747a01c15c9e8b61be9a Mon Sep 17 00:00:00 2001 From: myrmidex Date: Thu, 10 Jul 2025 12:00:50 +0200 Subject: [PATCH] Add enable/disable toggle for channels --- .../PlatformChannelsController.php | 18 ++ .../views/pages/channels/create.blade.php | 100 ++++++++++ resources/views/pages/channels/edit.blade.php | 104 ++++++++++ .../views/pages/channels/index.blade.php | 99 ++++++++++ resources/views/pages/channels/show.blade.php | 177 ++++++++++++++++++ routes/web.php | 1 + 6 files changed, 499 insertions(+) create mode 100644 resources/views/pages/channels/create.blade.php create mode 100644 resources/views/pages/channels/edit.blade.php create mode 100644 resources/views/pages/channels/index.blade.php create mode 100644 resources/views/pages/channels/show.blade.php diff --git a/app/Http/Controllers/PlatformChannelsController.php b/app/Http/Controllers/PlatformChannelsController.php index 24c8772..364301c 100644 --- a/app/Http/Controllers/PlatformChannelsController.php +++ b/app/Http/Controllers/PlatformChannelsController.php @@ -61,6 +61,13 @@ public function store(Request $request): RedirectResponse ->with('success', 'Channel created successfully!'); } + public function show(PlatformChannel $channel): View + { + $channel->load(['platformInstance', 'feeds']); + + return ViewFacade::make('pages.channels.show', compact('channel')); + } + public function edit(PlatformChannel $channel): View { $instances = PlatformInstance::where('is_active', true) @@ -95,4 +102,15 @@ public function destroy(PlatformChannel $channel): RedirectResponse return redirect()->route('channels.index') ->with('success', 'Channel deleted successfully!'); } + + public function toggle(PlatformChannel $channel): RedirectResponse + { + $newStatus = !$channel->is_active; + $channel->update(['is_active' => $newStatus]); + + $status = $newStatus ? 'activated' : 'deactivated'; + + return redirect()->route('channels.index') + ->with('success', "Channel {$status} successfully!"); + } } \ No newline at end of file diff --git a/resources/views/pages/channels/create.blade.php b/resources/views/pages/channels/create.blade.php new file mode 100644 index 0000000..0e18bc7 --- /dev/null +++ b/resources/views/pages/channels/create.blade.php @@ -0,0 +1,100 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Create New Channel

+

Add a new publishing channel to your platform

+
+ +
+
+ @csrf + +
+
+ + + @error('platform_instance_id') +

{{ $message }}

+ @enderror +
+ +
+ + +

The channel identifier (e.g., "technology", "news")

+ @error('name') +

{{ $message }}

+ @enderror +
+ +
+ + +

Human-readable name for the channel (optional)

+ @error('display_name') +

{{ $message }}

+ @enderror +
+ +
+ + +

Platform-specific channel ID (optional)

+ @error('channel_id') +

{{ $message }}

+ @enderror +
+ +
+ + + @error('description') +

{{ $message }}

+ @enderror +
+ +
+ + +
+
+ +
+ + Cancel + + +
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/pages/channels/edit.blade.php b/resources/views/pages/channels/edit.blade.php new file mode 100644 index 0000000..b1acfef --- /dev/null +++ b/resources/views/pages/channels/edit.blade.php @@ -0,0 +1,104 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Edit Channel

+

Update channel details

+
+ +
+
+ @csrf + @method('PUT') + +
+
+ + + @error('platform_instance_id') +

{{ $message }}

+ @enderror +
+ +
+ + + @error('name') +

{{ $message }}

+ @enderror +
+ +
+ + + @error('display_name') +

{{ $message }}

+ @enderror +
+ +
+ + + @error('channel_id') +

{{ $message }}

+ @enderror +
+ +
+ + + @error('description') +

{{ $message }}

+ @enderror +
+ +
+ is_active) ? 'checked' : '' }} + class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded"> + +
+
+ +
+ + @csrf + @method('DELETE') + + + +
+ + Cancel + + +
+
+ +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/pages/channels/index.blade.php b/resources/views/pages/channels/index.blade.php new file mode 100644 index 0000000..b999c70 --- /dev/null +++ b/resources/views/pages/channels/index.blade.php @@ -0,0 +1,99 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+

Platform Channels

+

Manage channels for publishing content

+
+ + Add New Channel + +
+ + @if(session('success')) +
+ {{ session('success') }} +
+ @endif + +
+ @if($channels->count() > 0) +
    + @foreach($channels as $channel) +
  • +
    +
    +
    + +
    +
    +
    +
    {{ $channel->display_name ?? $channel->name }}
    + @if(!$channel->is_active) + + Inactive + + @else + + Active + + @endif + + {{ $channel->platformInstance->name }} + +
    +
    {{ $channel->name }}
    + @if($channel->description) +
    {{ Str::limit($channel->description, 100) }}
    + @endif +
    +
    +
    + +
    + @csrf + +
    + + + + View + + + Edit + +
    + @csrf + @method('DELETE') + +
    +
    +
    +
  • + @endforeach +
+ @else +
+ +

No channels yet

+

Get started by adding your first publishing channel.

+ + Add New Channel + +
+ @endif +
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/pages/channels/show.blade.php b/resources/views/pages/channels/show.blade.php new file mode 100644 index 0000000..f70f8bb --- /dev/null +++ b/resources/views/pages/channels/show.blade.php @@ -0,0 +1,177 @@ +@extends('layouts.app') + +@section('content') +
+
+ +
+
+

{{ $channel->display_name ?? $channel->name }}

+

{{ $channel->platformInstance->name }} Channel

+
+ +
+ + @if(session('success')) +
+ {{ session('success') }} +
+ @endif + +
+ +
+
+
+
+

Channel Status

+

Enable or disable publishing to this channel

+
+ @if($channel->is_active) +
+ +
+ @else +
+ +
+ @endif +
+ +
+ + {{ $channel->is_active ? 'Active' : 'Inactive' }} + + +
+ @csrf + +
+
+ + @if(!$channel->is_active) +
+

+ + This channel is inactive. No articles will be published here until reactivated. +

+
+ @endif +
+
+ + +
+
+

Channel Details

+ +
+
+
Channel Name
+
{{ $channel->name }}
+
+ +
+
Display Name
+
{{ $channel->display_name ?? $channel->name }}
+
+ +
+
Platform
+
{{ $channel->platformInstance->name }}
+
+ +
+
Channel ID
+
{{ $channel->channel_id ?? 'Not set' }}
+
+ + @if($channel->language) +
+
Language
+
{{ $channel->language->name }}
+
+ @endif + +
+
Created
+
{{ $channel->created_at->format('M j, Y') }}
+
+
+ + @if($channel->description) +
+
Description
+
{{ $channel->description }}
+
+ @endif +
+
+
+ + + @if($channel->feeds->count() > 0) +
+
+

Connected Feeds

+

Feeds that route content to this channel

+
+
    + @foreach($channel->feeds as $feed) +
  • +
    +
    + @if($feed->type === 'rss') + + @else + + @endif +
    +

    {{ $feed->name }}

    +

    {{ $feed->url }}

    +
    + @if(!$feed->pivot->is_active) + + Route Inactive + + @endif +
    + +
    +
  • + @endforeach +
+
+ @else +
+
+ +

No feeds connected

+

This channel doesn't have any feeds routing content to it yet.

+ + Create Route + +
+
+ @endif +
+
+@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index a139558..0d0ae8f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,6 +22,7 @@ Route::post('/platforms/{platformAccount}/set-active', [App\Http\Controllers\PlatformAccountsController::class, 'setActive'])->name('platforms.set-active'); Route::resource('channels', App\Http\Controllers\PlatformChannelsController::class)->names('channels'); +Route::post('/channels/{channel}/toggle', [App\Http\Controllers\PlatformChannelsController::class, 'toggle'])->name('channels.toggle'); Route::resource('feeds', App\Http\Controllers\FeedsController::class)->names('feeds'); Route::get('/routing', [App\Http\Controllers\RoutingController::class, 'index'])->name('routing.index');