Witam, cały czas określone akcje robiłem w ten sposób
public function destroy(CommentArticle $commentArticle){
if ($commentArticle->user_id != Auth::id()){
return response()->json([
'error' => true
], 403);
}
CommentArticle::where('id', $commentArticle->id)
->where('user_id', Auth::id())
->delete();
ReplyCommentArticle::where('comment_id', $commentArticle->id)->delete();
return response()->json([
'error' => false
], 200);
}
lecz ostatnio pomyślałem że można to zrobić w ten sposób
public function destroy(CommentArticle $commentArticle){
if ($commentArticle->user_id != Auth::id()){
return response()->json([
'error' => true
], 403);
}
CommentArticle::where('id', $commentArticle->id)
->where('user_id', Auth::id())
->delete();
$reply = new ReplyCommentArticle();
$reply->delete($commentArticle->id);
return response()->json([
'error' => false
], 200);
}
``` myślę że drugi sposób jest nieco lepszy jednak nie mam co do tego pewności