1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* GitScrum v0.1. |
4
|
|
|
* |
5
|
|
|
* @author Renato Marinho <[email protected]> |
6
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace GitScrum\Http\Controllers; |
10
|
|
|
|
11
|
|
|
use GitScrum\Http\Requests\CommentRequest; |
12
|
|
|
use GitScrum\Models\Comment; |
13
|
|
|
|
14
|
|
|
class CommentController extends Controller |
15
|
|
|
{ |
16
|
|
|
public function store(CommentRequest $request) |
17
|
|
|
{ |
18
|
|
|
$data = [ |
19
|
|
|
'commentable_id' => $request->commentable_id, |
|
|
|
|
20
|
|
|
'commentable_type' => $request->commentable_type, |
|
|
|
|
21
|
|
|
'comment' => $request->comment, |
|
|
|
|
22
|
|
|
]; |
23
|
|
|
Comment::create($data); |
24
|
|
|
|
25
|
|
|
return back()->with('success', trans('Comment added successfully')); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function edit($id) |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
$comment = Comment::find($id); |
31
|
|
|
|
32
|
|
|
return view('comments.edit') |
|
|
|
|
33
|
|
|
->with('route', 'comments.update') |
34
|
|
|
->with('id', $comment->commentable_id) |
35
|
|
|
->with('type', $comment->commentable_type) |
36
|
|
|
->with('comment', $comment); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function update(CommentRequest $request, $id) |
40
|
|
|
{ |
41
|
|
|
$comment = Comment::find($id)->userActive()->firstOrFail(); |
42
|
|
|
$comment->comment = $request->comment; |
|
|
|
|
43
|
|
|
$comment->save(); |
44
|
|
|
|
45
|
|
|
return back()->with('success', trans('Comment updated successfully')); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function destroy($id) |
49
|
|
|
{ |
50
|
|
|
$comment = Comment::find($id)->userActive()->firstOrFail(); |
51
|
|
|
|
52
|
|
|
$comment->delete(); |
53
|
|
|
|
54
|
|
|
return back()->with('success', trans('Comment deleted successfully')); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.