#4: Added an admin screen to manage comments

This commit is contained in:
2018-09-21 15:00:07 +01:00
parent f2ba0e9475
commit 428c43a4c3
13 changed files with 126 additions and 1 deletions
@@ -16,6 +16,7 @@ use App\Http\Requests\SaveSettingsRequest;
use App\Label;
use App\Mail\TestMailConfig;
use App\Photo;
use App\PhotoComment;
use App\Services\GiteaService;
use App\Services\GithubService;
use App\Services\PhotoService;
@@ -140,6 +141,7 @@ class DefaultController extends Controller
$photoCount = Photo::all()->count();
$groupCount = Group::all()->count();
$labelCount = Label::all()->count();
$commentCount = PhotoComment::whereNotNull('approved_at')->count();
$userCount = User::where('is_activated', true)->count();
$minMetadataVersion = Photo::min('metadata_version');
@@ -157,6 +159,7 @@ class DefaultController extends Controller
return Theme::render('admin.index', [
'album_count' => $albumCount,
'app_version' => config('app.version'),
'comment_count' => $commentCount,
'group_count' => $groupCount,
'label_count' => $labelCount,
'memory_limit' => ini_get('memory_limit'),
@@ -0,0 +1,32 @@
<?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
]);
}
}
+5
View File
@@ -61,6 +61,11 @@ class PhotoComment extends Model
return $this->belongsTo(PhotoComment::class, 'parent_comment_id');
}
public function photo()
{
return $this->belongsTo(Photo::class);
}
public function textAsHtml()
{
$start = '<p>';
+4
View File
@@ -54,6 +54,10 @@ class AuthServiceProvider extends ServiceProvider
{
return $this->userHasAdminPermission($user, 'manage-albums');
});
Gate::define('admin:manage-comments', function ($user)
{
return $this->userHasAdminPermission($user, 'manage-comments');
});
Gate::define('admin:manage-groups', function ($user)
{
return $this->userHasAdminPermission($user, 'manage-groups');