-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Closed
Description
deleted_at column is set when I delete a record and trashed() is returning true for soft deleted record. But when I get the result it contains soft deleted records.
Controller: index() function
public function index()
{
$articles = Article::latest()->get();
return view( 'articles/view_articles' )->with( [
'articles' => $articles
] );
}
Model:
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Article extends Model
{
use SoftDeletes;
protected $fillable = [ 'name', 'url', 'description', 'status'];
public $dates = [ 'deleted_at' ];
}
Migration:
Schema::create( 'articles', function ( Blueprint $table ) {
$table->mediumInteger( 'id', true, true );
$table->string( 'name', 500 );
$table->string( 'url', 500 );
$table->text( 'description' );
$table->timestamps();
$table->softDeletes();
$table->enum( 'status', [ 'Y', 'N', 'D' ] )->default( 'N' );
}
Metadata
Metadata
Assignees
Labels
No labels