Browse Source

Add authorization to edit comment

pull/37/head
Nafies Luthfi 7 years ago
parent
commit
e9c725e263
  1. 2
      app/Http/Controllers/Issues/CommentController.php
  2. 2
      resources/views/projects/issues/index.blade.php
  3. 4
      resources/views/projects/issues/partials/comment-section.blade.php

2
app/Http/Controllers/Issues/CommentController.php

@ -44,6 +44,8 @@ class CommentController extends Controller
*/ */
public function update(Request $request, Issue $issue, Comment $comment) public function update(Request $request, Issue $issue, Comment $comment)
{ {
$this->authorize('update', $comment);
$commentData = $request->validate([ $commentData = $request->validate([
'body' => 'required|string|max:255', 'body' => 'required|string|max:255',
]); ]);

2
resources/views/projects/issues/index.blade.php

@ -45,7 +45,7 @@
</td> </td>
</tr> </tr>
@empty @empty
<tr><td colspan="6">{{ __('issue.empty') }}</td></tr>
<tr><td colspan="7">{{ __('issue.empty') }}</td></tr>
@endforelse @endforelse
</tbody> </tbody>
</table> </table>

4
resources/views/projects/issues/partials/comment-section.blade.php

@ -5,7 +5,9 @@
<strong>{{ $comment->creator->name }}</strong> <strong>{{ $comment->creator->name }}</strong>
</legend> </legend>
<div class="pull-right"> <div class="pull-right">
{{ link_to_route('projects.issues.show', __('app.edit'), [$project, $issue, 'action' => 'comment-edit', 'comment_id' => $comment->id], ['id' => 'edit-comment-'.$comment->id, 'class' => 'small', 'title' => __('comment.edit')]) }}
@can('update', $comment)
{{ link_to_route('projects.issues.show', __('app.edit'), [$project, $issue, 'action' => 'comment-edit', 'comment_id' => $comment->id], ['id' => 'edit-comment-'.$comment->id, 'class' => 'small', 'title' => __('comment.edit')]) }}
@endcan
</div> </div>
{!! nl2br($comment->body) !!} {!! nl2br($comment->body) !!}
</div> </div>

Loading…
Cancel
Save