Skip to content

Commit

Permalink
comment optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechu1997 committed Aug 9, 2019
1 parent ab45bc6 commit d23b73a
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions app/Http/Controllers/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,15 @@ public function create(Request $request)
'user_id' => $input['user_id']
]);
if ($request->input('spot_id')) {
DB::table('spot_comments')->insert([
'comment_id' => $comment['id'],
'spot_id' => $input['spot_id'],
'created_at' => \Carbon\Carbon::now(),
'updated_at' => \Carbon\Carbon::now()
]);
$comment = $comment->spots()->attach($input['spot_id']);
return response()->json([
'code' => 201,
'message' => 'comment added successfully',
'comment' => $comment
]);
}
if ($request->input('shop_id')) {
DB::table('shop_comments')->insert([
'comment_id' => $comment['id'],
'shop_id' => $input['shop_id'],
'created_at' => \Carbon\Carbon::now(),
'updated_at' => \Carbon\Carbon::now()
]);
$comment = $comment->shops()->attach($input['shop_id']);
return response()->json([
'code' => 201,
'message' => 'comment added successfully',
Expand Down

0 comments on commit d23b73a

Please sign in to comment.