mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2026-03-03 02:57:01 +00:00
Check invoice model props in validation to ensure cancelled invoices cannot be mutated
This commit is contained in:
@@ -67,7 +67,16 @@ class UpdateInvoiceRequest extends Request
|
||||
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||
$rules['status_id'] = 'bail|sometimes|not_in:5'; //do not allow cancelled invoices to be modfified.
|
||||
$rules['status_id'] = [
|
||||
'bail',
|
||||
'sometimes',
|
||||
'not_in:5',
|
||||
function ($attribute, $value, $fail) {
|
||||
if ($this->invoice->status_id == 5) {
|
||||
$fail(ctrans('texts.locked_invoice'));
|
||||
}
|
||||
}
|
||||
];
|
||||
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||
$rules['partial'] = 'bail|sometimes|nullable|numeric';
|
||||
$rules['amount'] = ['sometimes', 'bail', 'numeric', 'max:99999999999999'];
|
||||
|
||||
@@ -103,7 +103,6 @@ class BaseModel extends Model
|
||||
return $this->encodePrimaryKey($this->id);
|
||||
}
|
||||
|
||||
|
||||
public function shouldBeSearchable()
|
||||
{
|
||||
return config('scout.driver') === 'elastic';
|
||||
@@ -114,23 +113,6 @@ class BaseModel extends Model
|
||||
return (new Carbon($value))->format('Y-m-d');
|
||||
}
|
||||
|
||||
// public function __call($method, $params)
|
||||
// {
|
||||
// $entity = strtolower(class_basename($this));
|
||||
|
||||
// if ($entity) {
|
||||
// $configPath = "modules.relations.$entity.$method";
|
||||
|
||||
// if (config()->has($configPath)) {
|
||||
// $function = config()->get($configPath);
|
||||
|
||||
// return call_user_func_array([$this, $function[0]], $function[1]);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return parent::__call($method, $params);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
|
||||
Reference in New Issue
Block a user