Allow route model binding of trashed models
This commit is contained in:
parent
4bd372d7a6
commit
eb00e058d2
|
@ -11,6 +11,11 @@ class Contact extends Model
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
|
public function resolveRouteBinding($value, $field = null)
|
||||||
|
{
|
||||||
|
return $this->where($field ?? 'id', $value)->withTrashed()->firstOrFail();
|
||||||
|
}
|
||||||
|
|
||||||
public function organization()
|
public function organization()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Organization::class);
|
return $this->belongsTo(Organization::class);
|
||||||
|
|
|
@ -11,6 +11,11 @@ class Organization extends Model
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
|
public function resolveRouteBinding($value, $field = null)
|
||||||
|
{
|
||||||
|
return $this->where($field ?? 'id', $value)->withTrashed()->firstOrFail();
|
||||||
|
}
|
||||||
|
|
||||||
public function contacts()
|
public function contacts()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Contact::class);
|
return $this->hasMany(Contact::class);
|
||||||
|
|
|
@ -19,6 +19,11 @@ class User extends Authenticatable
|
||||||
'email_verified_at' => 'datetime',
|
'email_verified_at' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function resolveRouteBinding($value, $field = null)
|
||||||
|
{
|
||||||
|
return $this->where($field ?? 'id', $value)->withTrashed()->firstOrFail();
|
||||||
|
}
|
||||||
|
|
||||||
public function account()
|
public function account()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Account::class);
|
return $this->belongsTo(Account::class);
|
||||||
|
|
Loading…
Reference in New Issue