@extends('layouts.main_dashboard.app') @section('title', __('dashboard.Posts')) @section('page_heading', __('dashboard.Posts')) @section('breadcrumb') @endsection @section('actions') {{ __('dashboard.Create Post') }} @endsection @section('content')
@forelse($posts as $post)
@if($post->user->avatar) user @else {{ substr($post->user->name, 0, 1) }} @endif
{{ $post->user->name }} @if(!$post->is_published) {{ __('dashboard.Unpublished') }} @endif @if($post->type == 'poll') {{ __('dashboard.Poll') }} @endif
{{ $post->created_at->diffForHumans() }}
@if(auth()->id() == $post->user_id || auth()->user()->type == 'admin') @endif
{{ $post->body }}
@if($post->type == 'normal' && $post->attachments->count() > 0)
@foreach($post->attachments as $attachment) @if($attachment->file_type == 'video')
@else @endif @endforeach
@elseif($post->type == 'poll') @php $totalVotes = $post->total_votes; @endphp
@foreach($post->pollOptions as $option) @php $percentage = $totalVotes > 0 ? round(($option->votes_count / $totalVotes) * 100) : 0; @endphp
{{ $option->option_text }}
{{ $percentage }}% ({{ $option->votes_count }} {{ __('dashboard.votes') }})
@endforeach
{{ __('dashboard.Total Votes') }}: {{ $totalVotes }} | {{ $post->allow_multiple_choice ? __('dashboard.Multiple Choice') : __('dashboard.Single Choice') }}
@endif
@empty

{{ __('dashboard.No posts found yet.') }}

@endforelse
{{ $posts->links() }}
@endsection