2017-04-23 4 views
0

ブログアプリケーションのソフト削除に問題があります。私はソフト削除の後に、nullでないdeleted_at列を持つレコードがretrievevinigの後にまだ見える理由を知らない。私は何が間違っているのか分からない。例えば、私のようなリストレコードに見ている:ソフト削除が正しく動作しない

"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" 

マイポストモデルになります。

<?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'); 
    } 

} 

マイルート:

Route::get('dashboard/delete/{id}','[email protected]'); 

私のコントローラの方法:

public function deletePost($id){ 

     post::findOrFail($id)->delete(); 
     return redirect()->back()->withSuccess('Post has been deleted corectly.'); 

    } 

誰かが私の問題を助けてくれますか?私は非常に感謝して、挨拶をするだろう。

+0

どのようなlaravelバージョンですか? BTW:それは 'CałkaRiemann'ではなく'CałkaRiemanna'です。 –

+0

Iveはあなたの質問に役立つ類似の質問をいくつか見つけました。 http://stackoverflow.com/questions/22426165/laravel-soft-delete-posts and http://stackoverflow.com/questions/18041155/whysoft-deletedent-appear-in-query-results –

+0

Can後であなたがどのように投稿を取得しているかを教えてください。 – Brad

答えて

0

私は間違っていたことを知っています。問題は事後モデルのカウンターストラクチャーにありました。うまく動作するものを削除した後。

関連する問題