la_bloger/app/Http/Controllers/Admin/Concerns/ResolvesActiveChannel.php
2026-04-26 16:56:41 +02:00

22 lines
519 B
PHP

<?php
namespace App\Http\Controllers\Admin\Concerns;
use App\Models\Channel;
trait ResolvesActiveChannel
{
protected function activeChannel(): Channel
{
$channel = Channel::find(session('admin.active_channel_id')) ?? Channel::first();
if (! $channel) {
abort(redirect()->route('admin.settings.channels.create')
->with('error', 'Create a channel first.'));
}
session(['admin.active_channel_id' => $channel->id]);
return $channel;
}
}