<?php

namespace App\Http\Controllers\Admin;

use App\Facade\Theme;
use App\Facade\UserConfig;
use App\Http\Controllers\Controller;
use App\PhotoComment;
use Illuminate\Support\Facades\View;

class PhotoCommentController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
        View::share('is_admin', true);
    }

    public function index()
    {
        $this->authorizeAccessToAdminPanel();

        $comments = PhotoComment::with('photo')
            ->with('photo.album')
            ->orderBy('created_at', 'desc')
            ->paginate(UserConfig::get('items_per_page'));

        return Theme::render('admin.list_comments', [
            'comments' => $comments
        ]);
    }
}