1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Seongbae\Discuss\Http\Controllers; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use Illuminate\Http\Request; |
7
|
|
|
use Seongbae\Discuss\Models\Thread; |
8
|
|
|
use Seongbae\Discuss\Models\Channel; |
9
|
|
|
use Illuminate\Support\Facades\Auth; |
10
|
|
|
use Seongbae\Discuss\Models\Reply; |
11
|
|
|
use App\Http\Controllers\Controller; |
12
|
|
|
|
13
|
|
|
class RepliesController extends Controller |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Create a new RepliesController instance. |
17
|
|
|
*/ |
18
|
|
|
public function __construct() |
19
|
|
|
{ |
20
|
|
|
$this->middleware('auth'); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Persist a new reply. |
25
|
|
|
* |
26
|
|
|
* @param Thread $thread |
27
|
|
|
* @return \Illuminate\Http\RedirectResponse |
28
|
|
|
*/ |
29
|
|
|
public function store(Request $request, Channel $channel, Thread $thread) |
30
|
|
|
{ |
31
|
|
|
$this->validate(request(), [ |
32
|
|
|
'body'=>'required' |
33
|
|
|
]); |
34
|
|
|
|
35
|
|
|
$reply = $thread->addReply([ |
|
|
|
|
36
|
|
|
'body' => request('body'), |
37
|
|
|
'user_id' => Auth::id(), |
38
|
|
|
'user_type' => $thread->user_type |
39
|
|
|
], request('subscribe') == '1'); |
40
|
|
|
|
41
|
|
|
if ($request->ajax()) |
42
|
|
|
return $request->json([$reply], 200); |
|
|
|
|
43
|
|
|
else |
44
|
|
|
return redirect()->back(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Update the specified resource in storage. |
49
|
|
|
* |
50
|
|
|
* @param \Illuminate\Http\Request $request |
51
|
|
|
* @param \App\Thread $thread |
|
|
|
|
52
|
|
|
* @return \Illuminate\Http\Response |
53
|
|
|
*/ |
54
|
|
|
public function update(Request $request, Reply $reply) |
55
|
|
|
{ |
56
|
|
|
$this->validate(request(), [ |
57
|
|
|
'body'=>'required' |
58
|
|
|
]); |
59
|
|
|
|
60
|
|
|
$reply->update(request(['body'])); |
61
|
|
|
|
62
|
|
|
if ($request->ajax()) |
63
|
|
|
return $request->json([$reply], 200); |
|
|
|
|
64
|
|
|
else |
65
|
|
|
return redirect()->back(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Remove the specified resource from storage. |
70
|
|
|
* |
71
|
|
|
* @param \App\Thread $thread |
|
|
|
|
72
|
|
|
* @return \Illuminate\Http\Response |
73
|
|
|
*/ |
74
|
|
|
public function destroy(Reply $reply, Request $request) |
75
|
|
|
{ |
76
|
|
|
$reply->delete(); |
77
|
|
|
|
78
|
|
|
if ($request->ajax()) |
79
|
|
|
return $request->json([], 200); |
|
|
|
|
80
|
|
|
else |
81
|
|
|
return redirect()->back(); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.