ok, there you go. You may have accidentally created it, or your update method might not be working right and creating a duplicate instead of editing the original
Sep 6, 2019
36
Level 122
Level 2
public function create()
{
return view('news.create');
}
public function update(Request $request, News $news)
{
if(auth()->user()->id !== $news->user_id){
abort(401, "Please Login");
}
$this->validate($request,[
'subject'=>'required|min:10',
'body' => 'required|min:20'
]);
$news->update($request->all());
return redirect()->route('news.show', $news->slug)->withMessage('News Updated');
}
How can i avoid the duplicate content?
Level 122
That update method is passed the existing news instance which you then update, so it won't be that.
Level 2
@snapey what do you now suggest or think the problem is??
Level 2
Does anyone have solutions to this?
Level 122
well it depends what you are doing when a duplicate appears? All you have said is that one of the news items is a duplicate.
Did that happen recently? Does it keep happening? Could it have been created when you were developing your code?
Please or to participate in this conversation.