I seen this answer to a similar question here on StackOverflow: https://stackoverflow.com/a/40654005/1055279
Here I see
public function order() {
return $this->belongsToMany('Order')->withTrashed();
}
In my scenario I've Customer
models that have n Device
s
// Relation 1 to n from Customer model to Device model
public function devices()
{
return $this->hasMany('App\Device')->withTrashed();
}
Note I've added withTrashed, because I've ALWAYS the need to retrieve softDeleted data.
Also, I'm using ¯SoftDeletetrait on both models, and both table have
deleted_at` column.
The problem
Retriving devices from a customer model I got
message: "Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::withTrashed()"
Probably I'm using wrong syntax. I'm here to ask a kindly help.
- Laravel is @5.8.19
- PHP is @7.2.x
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire