39 lines
1017 B
PHP
39 lines
1017 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Legacy;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\ArtworkComment;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class ReceivedCommentsController extends Controller
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
$user = $request->user();
|
|
if (! $user) {
|
|
abort(403);
|
|
}
|
|
|
|
$hits = 33;
|
|
$currentPage = max(1, (int) $request->query('page', 1));
|
|
|
|
$base = ArtworkComment::with(['user', 'artwork'])
|
|
->whereHas('artwork', function ($q) use ($user) {
|
|
$q->where('user_id', $user->id)->where('is_approved', true);
|
|
})
|
|
->orderByDesc('created_at');
|
|
|
|
$comments = $base->paginate($hits);
|
|
|
|
return view('legacy::received-comments', [
|
|
'comments' => $comments,
|
|
'currentPage' => $currentPage,
|
|
'hits' => $hits,
|
|
'total' => $comments->total(),
|
|
]);
|
|
}
|
|
}
|