I have a parent model Library
which has many Books
. Eloquent makes it so easy to define the relationships. I have enabled softdeleting
on the book mode using the SoftDeletes
trait.
Problem:
When I delete a book instance, the deleted_at
attribute on the book instance is set to the current timestamp (as expected).
But when I query all the books that belong to the Library
, the result contains all the books, including the ones that were deleted.
I only want to get the books
that have not been deleted.
class Library extends Model {
public function books() {
return $this->hasMany(App\Book::class);
}
}
class Book extends Model {
use SoftDeletes;
public function library() {
return $this->belongsTo(App\Library::class, 'library_id');
}
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2hrzWOh
via IFTTT
Aucun commentaire:
Enregistrer un commentaire