Files
Kol-Manager/resources/views/social-hub/index.blade.php
2026-04-01 08:04:56 +07:00

143 lines
6.7 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@extends('layouts.app')
@section('title', 'Social Hub')
@section('page-title', 'Social Media Hub 📱')
@section('page-subtitle', 'Track your platform stats and posting frequency')
@section('content')
{{-- Platform Cards --}}
<div class="grid grid-cols-1 md:grid-cols-3 gap-5 mb-8">
@foreach($stats as $item)
@php $stat = $item['latest']; $platform = $item['platform']; @endphp
<div class="cat-card p-6">
<div class="flex items-center gap-3 mb-4">
<span class="text-3xl">{{ $stat?->platform_icon ?? '📱' }}</span>
<div>
<div class="font-bold text-gray-800 capitalize">{{ $platform }}</div>
<div class="text-xs text-gray-400">{{ $stat?->handle ?? 'Not connected' }}</div>
</div>
</div>
@if($stat)
<div class="grid grid-cols-2 gap-3">
<div class="bg-pink-50 rounded-2xl p-3 text-center">
<div class="text-xl font-extrabold text-pink-500">{{ $stat->formatted_followers }}</div>
<div class="text-xs text-gray-500">Followers</div>
</div>
<div class="bg-purple-50 rounded-2xl p-3 text-center">
<div class="text-xl font-extrabold text-purple-500">{{ $stat->engagement_rate }}%</div>
<div class="text-xs text-gray-500">Engagement</div>
</div>
<div class="bg-amber-50 rounded-2xl p-3 text-center">
<div class="text-xl font-extrabold text-amber-500">{{ number_format($stat->avg_views) }}</div>
<div class="text-xs text-gray-500">Avg Views</div>
</div>
<div class="bg-green-50 rounded-2xl p-3 text-center">
<div class="text-xl font-extrabold text-green-500">{{ number_format($stat->avg_likes) }}</div>
<div class="text-xs text-gray-500">Avg Likes</div>
</div>
</div>
<p class="text-xs text-gray-400 mt-3 text-right">Updated {{ $stat->recorded_date->format('d M Y') }}</p>
@else
<div class="text-center py-6 text-gray-400">
<p class="text-sm">No stats yet</p>
</div>
@endif
</div>
@endforeach
</div>
{{-- Update Stats --}}
<div class="cat-card p-6 mb-8" x-data="{ open: false, platform: 'instagram' }">
<div class="flex items-center justify-between">
<h2 class="font-bold text-gray-700 flex items-center gap-2">📊 Update Stats</h2>
<button class="btn-sakura text-sm" @click="open = !open">
<span x-text="open ? '✕ Close' : '+ Add Stats'"></span>
</button>
</div>
<form x-show="open" x-transition action="{{ route('social-hub.store-stats') }}" method="POST"
class="mt-5 grid grid-cols-2 lg:grid-cols-4 gap-4">
@csrf
<div class="col-span-2 lg:col-span-1">
<label class="text-xs font-semibold text-gray-600">Platform</label>
<select name="platform" x-model="platform" class="input-soft mt-1">
<option value="instagram">📸 Instagram</option>
<option value="tiktok">🎵 TikTok</option>
<option value="youtube">▶️ YouTube</option>
</select>
</div>
<div>
<label class="text-xs font-semibold text-gray-600">Handle</label>
<input type="text" name="handle" class="input-soft mt-1 text-sm" placeholder="@yourhandle">
</div>
<div>
<label class="text-xs font-semibold text-gray-600">Followers</label>
<input type="number" name="followers" class="input-soft mt-1 text-sm" placeholder="0" min="0" required>
</div>
<div>
<label class="text-xs font-semibold text-gray-600">Following</label>
<input type="number" name="following" class="input-soft mt-1 text-sm" placeholder="0" min="0">
</div>
<div>
<label class="text-xs font-semibold text-gray-600">Posts Count</label>
<input type="number" name="posts_count" class="input-soft mt-1 text-sm" placeholder="0" min="0">
</div>
<div>
<label class="text-xs font-semibold text-gray-600">Engagement Rate (%)</label>
<input type="number" name="engagement_rate" class="input-soft mt-1 text-sm" placeholder="0.00" step="0.01">
</div>
<div>
<label class="text-xs font-semibold text-gray-600">Avg Views</label>
<input type="number" name="avg_views" class="input-soft mt-1 text-sm" placeholder="0" min="0">
</div>
<div>
<label class="text-xs font-semibold text-gray-600">Avg Likes</label>
<input type="number" name="avg_likes" class="input-soft mt-1 text-sm" placeholder="0" min="0">
</div>
<div class="col-span-2 lg:col-span-4">
<button type="submit" class="btn-sakura text-sm px-6">📊 Save Stats</button>
</div>
</form>
</div>
{{-- Posting Frequency --}}
<div class="cat-card p-6">
<h2 class="font-bold text-gray-700 mb-4 flex items-center gap-2">📈 Posting Frequency</h2>
@if($postingFrequency->isNotEmpty())
<div class="overflow-x-auto">
<table class="table table-sm">
<thead>
<tr class="text-xs text-gray-500">
<th>Platform</th>
<th>Month</th>
<th>Posts</th>
</tr>
</thead>
<tbody>
@foreach($postingFrequency as $row)
<tr class="hover">
<td class="capitalize">{{ $row->platform }}</td>
<td>{{ $row->month }}</td>
<td>
<div class="flex items-center gap-2">
<div class="w-24 h-2 rounded-full bg-pink-100">
<div class="h-2 rounded-full bg-sakura" style="width: {{ min(100, $row->count * 10) }}%;"></div>
</div>
<span class="font-bold text-gray-700">{{ $row->count }}</span>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@else
<div class="text-center py-8 text-gray-400">
<span class="text-4xl block mb-2">📱</span>
<p class="text-sm">No posted content yet. Mark content as "Posted" to see frequency here.</p>
</div>
@endif
</div>
@endsection