Files
besttechfrom.eu/resources/views/products/show.blade.php
T

384 lines
22 KiB
PHP
Raw Normal View History

2026-02-06 14:56:56 +02:00
@extends('layouts.app')
@section('content')
2026-02-14 16:11:09 +02:00
<div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Success Message -->
@if(session('success'))
<div class="mb-6 rounded-md bg-green-50 p-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-green-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
</svg>
</div>
<div class="ml-3">
<p class="text-sm font-medium text-green-800">{{ session('success') }}</p>
</div>
</div>
</div>
@endif
2026-02-15 16:24:47 +02:00
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700">
2026-02-14 16:11:09 +02:00
<!-- Product Header -->
2026-02-15 16:24:47 +02:00
<div class="px-6 py-8 border-b border-gray-200 dark:border-gray-700">
2026-02-14 16:11:09 +02:00
<div class="flex flex-col md:flex-row md:items-start md:justify-between gap-4">
<div class="flex-1">
<div class="flex items-center gap-3 mb-3">
2026-02-15 16:24:47 +02:00
<h1 class="text-3xl font-bold text-gray-900 dark:text-white">{{ $product->title }}</h1>
2026-02-14 16:11:09 +02:00
<!-- Status Badges -->
@if($product->isPending())
<span class="inline-flex items-center px-2.5 py-0.5 rounded-md text-xs font-medium bg-yellow-100 text-yellow-800">
Pending Review
</span>
@elseif($product->isApproved())
<span class="inline-flex items-center px-2.5 py-0.5 rounded-md text-xs font-medium bg-green-100 text-green-800">
Approved
</span>
@elseif($product->isRejected())
<span class="inline-flex items-center px-2.5 py-0.5 rounded-md text-xs font-medium bg-red-100 text-red-800">
Rejected
</span>
@endif
</div>
2026-02-15 16:24:47 +02:00
<div class="flex items-center gap-3 text-sm text-gray-600 dark:text-gray-400">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-md bg-primary-100 dark:bg-primary-900 text-primary-800 dark:text-primary-200 font-medium">
2026-02-14 16:11:09 +02:00
{{ $product->category->name }}
</span>
<span>•</span>
<a href="{{ route('profile.show', $product->user) }}" class="hover:text-primary-600">
by {{ $product->user->name }}
</a>
<span>•</span>
<span>{{ $product->created_at->format('M j, Y') }}</span>
</div>
</div>
<!-- Action Buttons -->
<div class="flex items-center gap-2">
@auth
<!-- Upvote Button -->
<button
2026-02-15 16:24:47 +02:00
class="upvote-btn flex items-center gap-2 px-4 py-2 rounded-md border transition-colors {{ $product->isUpvotedBy(auth()->user()) ? 'border-primary-500 bg-primary-50 dark:bg-primary-900 text-primary-700 dark:text-primary-200' : 'border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:border-primary-500 hover:bg-primary-50 dark:hover:bg-primary-900' }}"
2026-02-14 16:11:09 +02:00
data-product-id="{{ $product->id }}"
data-upvoted="{{ $product->isUpvotedBy(auth()->user()) ? 'true' : 'false' }}">
<svg class="h-5 w-5" fill="{{ $product->isUpvotedBy(auth()->user()) ? 'currentColor' : 'none' }}" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7"></path>
</svg>
<span class="upvote-count font-semibold">{{ $product->upvotes()->count() }}</span>
</button>
<!-- Bookmark Button -->
<button
2026-02-15 16:24:47 +02:00
class="bookmark-btn p-2 rounded-md border transition-colors {{ $product->isBookmarkedBy(auth()->user()) ? 'border-primary-500 bg-primary-50 dark:bg-primary-900 text-primary-700 dark:text-primary-200' : 'border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:border-gray-400 dark:hover:border-gray-500' }}"
2026-02-14 16:11:09 +02:00
data-product-id="{{ $product->id }}"
data-bookmarked="{{ $product->isBookmarkedBy(auth()->user()) ? 'true' : 'false' }}">
<svg class="h-5 w-5" fill="{{ $product->isBookmarkedBy(auth()->user()) ? 'currentColor' : 'none' }}" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"></path>
</svg>
</button>
@else
2026-02-15 16:24:47 +02:00
<div class="flex items-center gap-2 px-4 py-2 rounded-md border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-gray-700 dark:text-gray-300">
2026-02-14 16:11:09 +02:00
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7"></path>
</svg>
<span class="font-semibold">{{ $product->upvotes()->count() }}</span>
</div>
@endauth
@can('edit-product', $product)
2026-02-15 16:24:47 +02:00
<a href="{{ route('products.edit', $product) }}" class="inline-flex items-center px-3 py-2 border border-gray-300 dark:border-gray-600 shadow-sm text-sm font-medium rounded-md text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600">
2026-02-14 16:11:09 +02:00
Edit
</a>
@endcan
@can('delete-product', $product)
<form action="{{ route('products.destroy', $product) }}" method="POST" onsubmit="return confirm('Are you sure you want to delete this product?');">
@csrf
@method('DELETE')
2026-02-15 16:24:47 +02:00
<button type="submit" class="inline-flex items-center px-3 py-2 border border-red-300 dark:border-red-700 shadow-sm text-sm font-medium rounded-md text-red-700 dark:text-red-400 bg-white dark:bg-gray-700 hover:bg-red-50 dark:hover:bg-red-900">
2026-02-14 16:11:09 +02:00
Delete
</button>
</form>
@endcan
</div>
</div>
</div>
<!-- Product Content -->
<div class="px-6 py-8">
<!-- Product Thumbnail -->
@if($product->thumbnail_url)
2026-02-15 16:24:47 +02:00
<div class="mb-8 rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700">
2026-02-14 16:11:09 +02:00
<img src="{{ $product->thumbnail_url }}"
alt="{{ $product->title }}"
2026-02-15 16:24:47 +02:00
class="w-full h-auto max-h-96 object-contain bg-gray-50 dark:bg-gray-900">
2026-02-06 14:56:56 +02:00
</div>
@endif
2026-02-14 16:11:09 +02:00
<!-- Product Description -->
<div class="mb-8">
2026-02-15 16:24:47 +02:00
<h2 class="text-xl font-semibold text-gray-900 dark:text-white mb-4">About</h2>
<p class="text-gray-700 dark:text-gray-300 text-lg leading-relaxed whitespace-pre-line">{{ $product->description }}</p>
2026-02-14 16:11:09 +02:00
</div>
2026-02-06 15:13:20 +02:00
2026-02-14 16:11:09 +02:00
<!-- Visit Website Button -->
<div class="mb-8">
<a href="{{ $product->website_url }}"
target="_blank"
rel="noopener noreferrer"
class="inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 shadow-sm">
Visit Website
<svg class="ml-2 h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"></path>
</svg>
</a>
</div>
<!-- Product Metadata -->
@if($product->isApproved() && $product->approved_at)
2026-02-15 16:24:47 +02:00
<div class="pt-6 border-t border-gray-200 dark:border-gray-700">
2026-02-14 16:11:09 +02:00
<dl class="grid grid-cols-1 gap-x-4 gap-y-4 sm:grid-cols-2">
<div>
2026-02-15 16:24:47 +02:00
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Submitted by</dt>
<dd class="mt-1 text-sm text-gray-900 dark:text-white">
<a href="{{ route('profile.show', $product->user) }}" class="hover:text-primary-600 dark:hover:text-primary-400">
2026-02-14 16:11:09 +02:00
{{ $product->user->name }}
</a>
</dd>
</div>
<div>
2026-02-15 16:24:47 +02:00
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Submitted on</dt>
<dd class="mt-1 text-sm text-gray-900 dark:text-white">{{ $product->created_at->format('F j, Y') }}</dd>
2026-02-14 16:11:09 +02:00
</div>
<div>
2026-02-15 16:24:47 +02:00
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Approved on</dt>
<dd class="mt-1 text-sm text-gray-900 dark:text-white">{{ $product->approved_at->format('F j, Y') }}</dd>
2026-02-14 16:11:09 +02:00
</div>
<div>
2026-02-15 16:24:47 +02:00
<dt class="text-sm font-medium text-gray-500 dark:text-gray-400">Category</dt>
<dd class="mt-1 text-sm text-gray-900 dark:text-white">{{ $product->category->name }}</dd>
2026-02-14 16:11:09 +02:00
</div>
</dl>
</div>
@endif
</div>
</div>
<!-- Comments Section -->
2026-02-15 16:24:47 +02:00
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 mt-6">
<div class="px-6 py-4 border-b border-gray-200 dark:border-gray-700">
<h2 class="text-xl font-semibold text-gray-900 dark:text-white">
2026-02-14 16:11:09 +02:00
Comments ({{ $product->comments()->count() }})
</h2>
</div>
<div class="px-6 py-6">
@auth
<!-- Comment Form -->
<form action="{{ route('products.comments.store', $product) }}" method="POST" class="mb-8">
@csrf
<div>
<label for="body" class="sr-only">Add a comment</label>
<textarea
id="body"
name="body"
rows="3"
required
maxlength="1000"
placeholder="Share your thoughts about this product..."
class="block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 sm:text-sm @error('body') border-red-300 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500 @enderror">{{ old('body') }}</textarea>
@error('body')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div class="mt-3 flex justify-end">
<button type="submit" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
Post Comment
</button>
</div>
</form>
@else
2026-02-15 16:24:47 +02:00
<div class="text-center py-6 bg-gray-50 dark:bg-gray-900 rounded-lg mb-8">
<p class="text-gray-600 dark:text-gray-400">
2026-02-14 16:11:09 +02:00
<a href="{{ route('login') }}" class="font-medium text-primary-600 hover:text-primary-500">Log in</a>
to post a comment
</p>
</div>
@endauth
<!-- Comments List -->
<div class="space-y-6">
@forelse($product->comments as $comment)
<div class="flex gap-4">
<!-- Avatar -->
<div class="flex-shrink-0">
@if($comment->user->avatar_url)
<img src="{{ $comment->user->avatar_url }}"
alt="{{ $comment->user->name }}"
class="h-10 w-10 rounded-full object-cover">
2026-02-06 15:13:20 +02:00
@else
2026-02-14 16:11:09 +02:00
<div class="h-10 w-10 rounded-full bg-gradient-to-br from-primary-500 to-accent-500 flex items-center justify-center text-white font-semibold">
{{ strtoupper(substr($comment->user->name, 0, 1)) }}
2026-02-06 15:13:20 +02:00
</div>
2026-02-14 16:11:09 +02:00
@endif
2026-02-06 14:56:56 +02:00
</div>
2026-02-14 16:11:09 +02:00
<!-- Comment Content -->
<div class="flex-1 min-w-0">
<div class="flex items-center justify-between">
<div class="flex items-center gap-2">
2026-02-15 16:24:47 +02:00
<a href="{{ route('profile.show', $comment->user) }}" class="font-medium text-gray-900 dark:text-white hover:text-primary-600 dark:hover:text-primary-400">
2026-02-14 16:11:09 +02:00
{{ $comment->user->name }}
</a>
2026-02-15 16:24:47 +02:00
<span class="text-gray-500 dark:text-gray-400 text-sm">·</span>
<span class="text-gray-500 dark:text-gray-400 text-sm">{{ $comment->created_at->diffForHumans() }}</span>
2026-02-06 15:13:20 +02:00
</div>
2026-02-14 16:11:09 +02:00
@can('delete-comment', $comment)
<form action="{{ route('comments.destroy', $comment) }}" method="POST" onsubmit="return confirm('Are you sure you want to delete this comment?');">
@csrf
@method('DELETE')
<button type="submit" class="text-sm text-red-600 hover:text-red-700">
Delete
</button>
</form>
@endcan
2026-02-06 15:13:20 +02:00
</div>
2026-02-15 16:24:47 +02:00
<p class="mt-2 text-gray-700 dark:text-gray-300 whitespace-pre-line">{{ $comment->body }}</p>
2026-02-06 14:56:56 +02:00
</div>
</div>
2026-02-14 16:11:09 +02:00
@empty
2026-02-15 16:24:47 +02:00
<div class="text-center py-12 bg-gray-50 dark:bg-gray-900 rounded-lg">
2026-02-14 16:11:09 +02:00
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"></path>
</svg>
2026-02-15 16:24:47 +02:00
<p class="mt-2 text-gray-600 dark:text-gray-400">No comments yet. Be the first to share your thoughts!</p>
2026-02-14 16:11:09 +02:00
</div>
@endforelse
2026-02-06 14:56:56 +02:00
</div>
</div>
</div>
2026-02-06 15:13:20 +02:00
2026-02-14 16:11:09 +02:00
<!-- Moderator Actions -->
@can('approve-product')
@if($product->isPending() || $product->isRejected())
<div class="bg-yellow-50 border border-yellow-200 rounded-lg mt-6">
<div class="px-6 py-4 border-b border-yellow-200 bg-yellow-100">
<h3 class="text-lg font-semibold text-yellow-900">Moderator Actions</h3>
</div>
<div class="px-6 py-4 flex gap-3">
<form action="{{ route('products.approve', $product) }}" method="POST">
@csrf
<button type="submit" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700">
Approve Product
</button>
</form>
<form action="{{ route('products.reject', $product) }}" method="POST" onsubmit="return confirm('Are you sure you want to reject this product?');">
@csrf
<button type="submit" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-700">
Reject Product
</button>
</form>
</div>
</div>
@endif
@endcan
<!-- Back Button -->
<div class="mt-6">
2026-02-15 16:24:47 +02:00
<a href="{{ route('products.index') }}" class="inline-flex items-center text-sm font-medium text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white">
2026-02-14 16:11:09 +02:00
<svg class="mr-2 h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
</svg>
Back to Products
</a>
</div>
</div>
2026-02-06 15:13:20 +02:00
@push('scripts')
<script>
// Upvote functionality
document.querySelectorAll('.upvote-btn').forEach(button => {
button.addEventListener('click', async function() {
const productId = this.getAttribute('data-product-id');
const isUpvoted = this.getAttribute('data-upvoted') === 'true';
try {
const response = await fetch(`/products/${productId}/upvote`, {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Content-Type': 'application/json',
'Accept': 'application/json',
},
});
const data = await response.json();
if (data.success) {
// Update button state
this.setAttribute('data-upvoted', data.upvoted ? 'true' : 'false');
2026-02-14 16:11:09 +02:00
const svg = this.querySelector('svg');
2026-02-06 15:13:20 +02:00
if (data.upvoted) {
2026-02-14 16:11:09 +02:00
this.classList.remove('border-gray-300', 'bg-white', 'text-gray-700', 'hover:border-primary-500', 'hover:bg-primary-50');
this.classList.add('border-primary-500', 'bg-primary-50', 'text-primary-700');
svg.setAttribute('fill', 'currentColor');
2026-02-06 15:13:20 +02:00
} else {
2026-02-14 16:11:09 +02:00
this.classList.remove('border-primary-500', 'bg-primary-50', 'text-primary-700');
this.classList.add('border-gray-300', 'bg-white', 'text-gray-700', 'hover:border-primary-500', 'hover:bg-primary-50');
svg.setAttribute('fill', 'none');
2026-02-06 15:13:20 +02:00
}
// Update count
this.querySelector('.upvote-count').textContent = data.upvotesCount;
}
} catch (error) {
console.error('Error toggling upvote:', error);
}
});
});
// Bookmark functionality
document.querySelectorAll('.bookmark-btn').forEach(button => {
button.addEventListener('click', async function() {
const productId = this.getAttribute('data-product-id');
const isBookmarked = this.getAttribute('data-bookmarked') === 'true';
try {
const response = await fetch(`/products/${productId}/bookmark`, {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Content-Type': 'application/json',
'Accept': 'application/json',
},
});
const data = await response.json();
if (data.success) {
// Update button state
this.setAttribute('data-bookmarked', data.bookmarked ? 'true' : 'false');
2026-02-14 16:11:09 +02:00
const svg = this.querySelector('svg');
2026-02-06 15:13:20 +02:00
if (data.bookmarked) {
2026-02-14 16:11:09 +02:00
this.classList.remove('border-gray-300', 'bg-white', 'text-gray-700', 'hover:border-gray-400');
this.classList.add('border-primary-500', 'bg-primary-50', 'text-primary-700');
svg.setAttribute('fill', 'currentColor');
2026-02-06 15:13:20 +02:00
} else {
2026-02-14 16:11:09 +02:00
this.classList.remove('border-primary-500', 'bg-primary-50', 'text-primary-700');
this.classList.add('border-gray-300', 'bg-white', 'text-gray-700', 'hover:border-gray-400');
svg.setAttribute('fill', 'none');
2026-02-06 15:13:20 +02:00
}
}
} catch (error) {
console.error('Error toggling bookmark:', error);
}
});
});
</script>
@endpush
2026-02-06 14:56:56 +02:00
@endsection