0

I'm trying to get soft deleting work on laravel voyager but everytime I delete a post it's also deleted in my database.

here is my post model :

<?php

namespace App;

use TCG\Voyager\Traits\Resizable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Category;


class Post extends Model
{
  use Resizable;
  use SoftDeletes;

  protected $dates = ['deleted_at'];

  public function category()
  {
    return $this->belongsTo(Category::class);
  }

  public function scopeIspublished($query)
  {
    return $query->where('status','published');
  }
} 

I added a column deleted_at to my posts table as well.

Thanks for helping

  • Have you actually added soft deletes in your migrations as well? https://laravel.com/docs/5.6/eloquent#soft-deleting Also please note that soft deletes are *not* the solution 99% of the time. Just backup the database regularly. You will run into unexpected situations where you reuse a title of a post from a deleted post 4 years ago, and the app will throw a 500 error because that title is already in your database. – Loek Jul 10 '18 at 11:10
  • Thank you Loek I think I'll go with the database backup ;D – maxime grangier Jul 12 '18 at 07:02

0 Answers0