@php use App\Services\Social\SocialPostAggregator; // Per-channel action routes (publish/destroy take the post id positionally). $routes = [ 'instagram' => ['publish' => 'user.instagram.posts.publish', 'destroy' => 'user.instagram.posts.destroy', 'list' => url('/instagram/posts')], 'facebook' => ['publish' => 'user.facebook.posts.publish', 'destroy' => 'user.facebook.posts.destroy', 'list' => url('/facebook/posts')], 'tiktok' => ['publish' => null, 'destroy' => 'user.tiktok.posts.destroy', 'list' => url('/tiktok/posts')], ]; $chGlyph = [ 'instagram' => '', 'facebook' => '', 'tiktok' => '', 'threads' => '', 'linkedin' => '', 'x' => '', ]; $chColor = ['instagram' => '#C13584', 'facebook' => '#1877F2', 'tiktok' => '#010101', 'threads' => '#000000', 'linkedin' => '#0A66C2', 'x' => '#0F1419']; // Any channel without an entry falls back to a neutral style + its own posts // page, so a newly-added channel can never 500 this page (same as the calendar). $chColorOf = fn ($c) => $chColor[$c] ?? '#64748B'; $chGlyphOf = fn ($c) => $chGlyph[$c] ?? ''; $routeOf = fn ($c) => $routes[$c] ?? ['publish' => null, 'destroy' => null, 'list' => url('/'.$c.'/posts')]; $filterUrl = fn ($k, $v) => url('/social/posts').'?'.http_build_query(array_filter([ 'status' => $k === 'status' ? $v : $status, 'platform' => $k === 'platform' ? $v : $channel, ])); @endphp
{{ __('Social') }} · {{ __('Posts') }}

{{ __('All') }} {{ __('posts') }}

{{ __('Every scheduled post, draft and publish across all your social channels — in one place.') }}

{{ __('Calendar') }} @if (count($channels))
@endif
@if (session('success'))
{{ session('success') }}
@endif @if (session('error'))
{{ session('error') }}
@endif {{-- Filters --}}
{{ __('Filter') }}
@foreach (['' => __('All statuses').' ('.$counts['all'].')', 'scheduled' => __('Scheduled').' ('.$counts['scheduled'].')', 'published' => __('Published').' ('.$counts['published'].')', 'draft' => __('Draft').' ('.$counts['draft'].')', 'failed' => __('Failed').' ('.$counts['failed'].')'] as $k => $lbl) {{ $lbl }} @endforeach
{{ __('All platforms') }} @foreach (['instagram' => 'Instagram', 'facebook' => 'Facebook', 'tiktok' => 'TikTok', 'threads' => 'Threads', 'linkedin' => 'LinkedIn', 'x' => 'X'] as $k => $lbl) {!! $chGlyphOf($k) !!}{{ $lbl }} @endforeach
@if ($posts->isEmpty())
{{ __('No posts yet') }}

{{ count($channels) ? __('Create a post from one of your connected channels.') : __('Connect Instagram, Facebook or TikTok to start posting.') }}

@else
@foreach ($posts as $p) @php [$sc, $sl] = SocialPostAggregator::statusStyle($p['status']); $r = $routeOf($p['channel']); $when = $p['scheduled_at'] ?: $p['published_at']; @endphp
{{-- media --}}
@if ($p['media_url']) @else
@endif {!! $chGlyphOf($p['channel']) !!}
{{ $sl }} {{ $when ? $when->timezone(safe_timezone(config('app.timezone'),'Asia/Calcutta'))->format('j M Y, g:i A') : '' }}
{{ \Illuminate\Support\Str::limit(strip_tags($p['text']), 160) ?: '—' }}
! ($p['status'] === 'failed' && $p['error'])])>{{ $p['status'] === 'failed' ? \Illuminate\Support\Str::limit($p['error'], 120) : '' }}
@if($p['account_avatar'])@else{!! $chGlyphOf($p['channel']) !!}@endif {{ $p['account_name'] }}
{{-- Status-aware actions. [data-when] lists the statuses each button shows for; the poller toggles them live as status changes. Forms submit via AJAX. --}}
{{ __('Manage') }} @if ($r['publish'])
! in_array($p['status'], ['draft','scheduled'], true)])>@csrf
$p['status'] !== 'failed'])>@csrf
@else ! in_array($p['status'], ['published','draft'], true)])>{{ __('Details') }} @endif @if ($r['destroy'])
$p['status'] !== 'processing'])>@csrf @method('DELETE')
$p['status'] !== 'scheduled'])>@csrf @method('DELETE')
! in_array($p['status'], ['draft','failed','published'], true)])>@csrf @method('DELETE')
@endif
@endforeach
@endif