I have a problem with soft deleting posts in blog application. I don't know why after soft deleting, records with not null deleted_at columns are still visible after retrievinig. I don't know what's wrong. For example I'm seeing on the list record like :
"id" => 7
"topic" => "Całka Riemann"
"content" => "Ważne pojęcie w analizie matematycznej"
"category_id" => 3
"user_id" => 16
"created_at" => "2017-04-16 17:38:15"
"updated_at" => "2017-04-23 21:49:41"
"deleted_at" => "2017-04-23 21:49:41"
My post Model looks:
<?php
namespace artSite;
use Illuminate\Database\Eloquent\Model;
use artSite\category;
use Illuminate\Database\Eloquent\SoftDeletes;
class post extends Model
{
use SoftDeletes;
protected $table = 'posts';
protected $fillable = ['topic', 'content', 'category_id','user_id'];
protected $dates = ['deleted_at'];
public function __construct() {
}
public function category(){
return $this->belongsTo('artSite\category');
}
public function user(){
return $this->belongsTo('artSite\user');
}
}
My Route:
Route::get('dashboard/delete/{id}','adminPanelController@deletePost');
My controller's method:
public function deletePost($id){
post::findOrFail($id)->delete();
return redirect()->back()->withSuccess('Post has been deleted corectly.');
}
Could someone help me with my problem? I would be very grateful, greetings.