current state
This commit is contained in:
38
app/Http/Controllers/Legacy/ReceivedCommentsController.php
Normal file
38
app/Http/Controllers/Legacy/ReceivedCommentsController.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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;
|
||||
$page = 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,
|
||||
'page' => $page,
|
||||
'hits' => $hits,
|
||||
'total' => $comments->total(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user