Trouble deleting a post

Posted 11 months ago by Twittler

Hi guys, i'm having a strange error while deleting a post, it seems i cant select db value can u help me with this. dd($posts->exists) shows false and i confused why.

Controller :

<php public function getDeletePost(Post $post_id) {

    $post = Post::where('id', $post_id)->first();
    dd($post_id->exists);
    //$post->delete();

    return redirect()->route('dashboard')->with(['message' => 'post deleted']);


}

model :

<php class Post extends Model {

public function user() {
    return $this -> belongsTo('App\User');
}

}

and Route :

<php Route::get('/post-delete', [ 'uses' => '[email protected]', 'as' => 'post.delete', 'middleware' => 'auth'

And sorry for dumb question.

Please sign in or create an account to participate in this conversation.