这就是我删除记录的方法,请您建议我删除记录的最佳方法是什么。
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');
}
}