diff --git a/app/Nova/Comment.php b/app/Nova/Comment.php index a88e1689..3b0c7e4e 100644 --- a/app/Nova/Comment.php +++ b/app/Nova/Comment.php @@ -2,6 +2,7 @@ namespace App\Nova; +use Illuminate\Http\Request; use Laravel\Nova\Fields\DateTime; use Laravel\Nova\Fields\Markdown; use Laravel\Nova\Fields\MorphTo; @@ -17,35 +18,53 @@ class Comment extends Resource 'id', 'text', ]; + public static function authorizedToCreate(Request $request) + { + return auth() + ->user() + ?->hasRole('super-admin'); + } + + public function authorizedToUpdate(Request $request) + { + return auth() + ->user() + ?->hasRole('super-admin'); + } + public function fields(NovaRequest $request) { return [ Text::make(__('Title'), function (CommentModel $comment) { return $comment->topLevel()->commentable?->commentableName() ?? 'Deleted...'; - })->readonly(), + }) + ->readonly(), - MorphTo::make(__('Commentator'), 'commentator')->types([ - User::class, - ]), + MorphTo::make(__('Commentator'), 'commentator') + ->types([ + User::class, + ]), Markdown::make(__('Original text'), 'original_text'), Text::make('', function (CommentModel $comment) { - if (! $url = $comment?->commentUrl()) { + if (!$url = $comment?->commentUrl()) { return ''; } return "".__('Show').""; - })->asHtml(), + }) + ->asHtml(), - Text::make(__('Status'), function(CommentModel $comment) { + Text::make(__('Status'), function (CommentModel $comment) { if ($comment->isApproved()) { return "