1
votes

anyone can help me?

how to resolve ->

BadMethodCallException
Call to undefined method App\ModalName::onlyTrashed()

my controller ->

public function destroy(Abc $abc)
    {
        $abc= Abc::destroy($abc->id)->get();
        return redirect('/dir/abcdir')-> with('delete', 'aaa');
    }
2
do u use soft-delete in your model? - TsaiKoga
Please post the code of your Model - Akshay Khale

2 Answers

2
votes

According to the docs, you need to use traits 'SoftDeletes'.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Flight extends Model
{
    use SoftDeletes;
}

PS: Please post complete code of your controller and model.

2
votes

For SoftDelete to work in Laravel Eloquent Model

  1. You must use SoftDeletes Trait
  2. Table schema should have $table->softDeletes(); which will add deleted_at column in the table.

Reference: Eloquent Soft-Delete