fixed recurring route binding and scope

This commit is contained in:
Denis Duliçi
2022-06-05 14:07:00 +03:00
parent 5b3688aaac
commit 776bc44514
6 changed files with 56 additions and 26 deletions

View File

@ -632,6 +632,24 @@ class Document extends Model
return $actions;
}
/**
* Retrieve the model for a bound value.
*
* @param mixed $value
* @param string|null $field
* @return \Illuminate\Database\Eloquent\Model|null
*/
public function resolveRouteBinding($value, $field = null)
{
$query = $this->where('id', $value);
if (request()->route()->hasParameter('recurring_invoice') || request()->route()->hasParameter('recurring_bill')) {
$query->isRecurring();
}
return $query->firstOrFail();
}
protected static function newFactory(): Factory
{
return DocumentFactory::new();