1 | <?php |
||
2 | |||
3 | namespace App\Http\Controllers; |
||
4 | |||
5 | use App\Http\Requests\CommentRequest as StoreRequest; |
||
6 | use App\Models\Comment; |
||
7 | use Illuminate\Support\Facades\Log; |
||
8 | |||
9 | class CommentController extends Controller |
||
10 | { |
||
11 | public function __construct() |
||
12 | { |
||
13 | parent::__construct(); |
||
14 | $this->middleware('permission:comments.edit', ['only' => 'delete']); |
||
15 | } |
||
16 | |||
17 | public function store(StoreRequest $request) |
||
18 | { |
||
19 | Log::info('Comment created by '.backpack_user()->firstname); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
20 | |||
21 | return Comment::create([ |
||
22 | 'commentable_id' => $request->input('commentable_id'), |
||
23 | 'commentable_type' => $request->input('commentable_type'), |
||
24 | 'action' => $request->input('action') ?? 0, |
||
25 | 'body' => $request->input('body'), |
||
26 | 'author_id' => backpack_user()->id, |
||
0 ignored issues
–
show
|
|||
27 | ]); |
||
28 | } |
||
29 | |||
30 | public function update(Comment $comment, StoreRequest $request) |
||
31 | { |
||
32 | $comment->update([ |
||
33 | 'body' => $request->input('body'), |
||
34 | ]); |
||
35 | } |
||
36 | |||
37 | public function destroy(Comment $comment) |
||
38 | { |
||
39 | $comment->delete(); |
||
40 | } |
||
41 | } |
||
42 |