これは私がレコードを削除する方法です。あなたがレコードを削除する最良の方法は何ですか?ユーザー関連のモデルレコードを削除する最良の方法
public function delete_post($id) {
//Check if id is numeric and exists
if((is_numeric($id)) && (!empty($id)))
{
$post = Post::find($id);
// check if this id belongs to user (User has author)
if(Auth::id() == $post->user_id){
Post::with('likes')->whereId($id)->delete();
}else{
Session::flash('error', 'You can't delete this.
}
}else{
Session::flash('error', 'Problem with your input');
}
}
)それは 数値であるかどうかをチェックするために持っていけないはい我々としても取引でこれをラップすることができますが、私は、ユーザーのレコードを削除するための最良の方法を必要としています。 –