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łka Riemann이 아니라 Całka Riemanna입니다. –

+0

Ive는 귀하의 질문에 도움이 될만한 유사한 질문을 발견했습니다. http://stackoverflow.com/questions/22426165/laravel-soft-delete-posts 및 http://stackoverflow.com/questions/18041155/why-soft-deleted-entities-appear-in-query-results –

+0

Can 나중에 어떻게 게시물을 가져 오는 지 보여 주시겠습니까? – Brad

답변

0

좋아, 나는 틀린 것을 알고있다. 문제는 사후 모델의 변호인과 함께있었습니다. 잘 작동하는 하나를 삭제 한 후.