Files
besttechfrom.eu/resources/views/products/manage.blade.php
T
2026-02-06 14:56:56 +02:00

169 lines
10 KiB
PHP

@extends('layouts.app')
@section('content')
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<h1 class="mb-4">Product Management</h1>
@if(session('success'))
<div class="alert alert-success alert-dismissible fade show" role="alert">
{{ session('success') }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif
<!-- Status Filter -->
<div class="card mb-4">
<div class="card-body">
<div class="row">
<div class="col-md-12">
<h5 class="mb-3">Filter by Status</h5>
<a href="{{ route('products.manage') }}"
class="btn btn-sm {{ !request('status') || request('status') == 'pending' ? 'btn-warning' : 'btn-outline-warning' }}">
Pending ({{ $statusCounts['pending'] }})
</a>
<a href="{{ route('products.manage', ['status' => 'approved']) }}"
class="btn btn-sm {{ request('status') == 'approved' ? 'btn-success' : 'btn-outline-success' }}">
Approved ({{ $statusCounts['approved'] }})
</a>
<a href="{{ route('products.manage', ['status' => 'rejected']) }}"
class="btn btn-sm {{ request('status') == 'rejected' ? 'btn-danger' : 'btn-outline-danger' }}">
Rejected ({{ $statusCounts['rejected'] }})
</a>
</div>
</div>
</div>
</div>
<!-- Products Table -->
<div class="card">
<div class="card-body">
@if($products->count() > 0)
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Thumbnail</th>
<th>Title</th>
<th>Category</th>
<th>Submitted By</th>
<th>Status</th>
<th>Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($products as $product)
<tr>
<td>
@if($product->thumbnail_url)
<img src="{{ $product->thumbnail_url }}"
alt="{{ $product->title }}"
style="width: 60px; height: 60px; object-fit: cover;"
class="rounded">
@else
<div class="bg-light d-flex align-items-center justify-content-center rounded"
style="width: 60px; height: 60px;">
<span class="text-muted small">No img</span>
</div>
@endif
</td>
<td>
<a href="{{ route('products.show', $product) }}" class="fw-bold text-decoration-none">
{{ $product->title }}
</a>
<br>
<small class="text-muted">{{ Str::limit($product->description, 60) }}</small>
</td>
<td>
<span class="badge bg-secondary">{{ $product->category->name }}</span>
</td>
<td>
<a href="{{ route('profile.show', $product->user) }}">
{{ $product->user->name }}
</a>
</td>
<td>
@if($product->isPending())
<span class="badge bg-warning text-dark">Pending</span>
@elseif($product->isApproved())
<span class="badge bg-success">Approved</span>
@elseif($product->isRejected())
<span class="badge bg-danger">Rejected</span>
@endif
</td>
<td>
<small>{{ $product->created_at->format('M j, Y') }}</small>
<br>
<small class="text-muted">{{ $product->created_at->diffForHumans() }}</small>
</td>
<td>
<div class="btn-group btn-group-sm" role="group">
@if($product->isPending() || $product->isRejected())
<form action="{{ route('products.approve', $product) }}" method="POST" class="d-inline">
@csrf
<button type="submit" class="btn btn-success btn-sm" title="Approve">
✓
</button>
</form>
@endif
@if($product->isPending() || $product->isApproved())
<form action="{{ route('products.reject', $product) }}" method="POST" class="d-inline">
@csrf
<button type="submit"
class="btn btn-danger btn-sm"
title="Reject"
onclick="return confirm('Are you sure you want to reject this product?');">
✗
</button>
</form>
@endif
<a href="{{ route('products.show', $product) }}" class="btn btn-info btn-sm" title="View">
👁
</a>
@can('edit-product', $product)
<a href="{{ route('products.edit', $product) }}" class="btn btn-primary btn-sm" title="Edit">
✎
</a>
@endcan
@can('delete-product', $product)
<form action="{{ route('products.destroy', $product) }}" method="POST" class="d-inline">
@csrf
@method('DELETE')
<button type="submit"
class="btn btn-danger btn-sm"
title="Delete"
onclick="return confirm('Are you sure you want to delete this product permanently?');">
🗑
</button>
</form>
@endcan
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<!-- Pagination -->
<div class="d-flex justify-content-center mt-4">
{{ $products->appends(['status' => request('status')])->links() }}
</div>
@else
<div class="alert alert-info">
No products found with status: {{ request('status', 'pending') }}
</div>
@endif
</div>
</div>
</div>
</div>
</div>
@endsection