closed #2420 Fixed : Document and Transaction recurring template edit issue.

This commit is contained in:
Cüneyt Şentürk
2022-06-03 20:02:54 +03:00
parent 5d409b142a
commit d2d5073efa
3 changed files with 26 additions and 17 deletions

View File

@ -3,6 +3,7 @@
namespace App\Http\Requests\Banking;
use App\Abstracts\Http\FormRequest;
use App\Models\Banking\Transaction as Model;
use App\Utilities\Date;
class Transaction extends FormRequest
@ -14,15 +15,15 @@ class Transaction extends FormRequest
*/
public function rules()
{
$attachment = 'nullable';
$type = $this->request->get('type', Model::INCOME_TYPE);
if ($this->files->get('attachment')) {
$attachment = 'mimes:' . config('filesystems.mimes') . '|between:0,' . config('filesystems.max_size') * 1024;
}
$type = config('type.transaction.' . $type . '.route.parameter');
// Check if store or update
if ($this->getMethod() == 'PATCH') {
$id = $this->transaction->getAttribute('id');
$model = $this->isApi() ? 'document' : $type;
$id = is_numeric($this->$model) ? $this->$model : $this->{$model}->getAttribute('id');
} else {
$id = null;
}
@ -30,6 +31,12 @@ class Transaction extends FormRequest
// Get company id
$company_id = (int) $this->request->get('company_id');
$attachment = 'nullable';
if ($this->files->get('attachment')) {
$attachment = 'mimes:' . config('filesystems.mimes') . '|between:0,' . config('filesystems.max_size') * 1024;
}
return [
'type' => 'required|string',
'number' => 'required|string|unique:transactions,NULL,' . $id . ',id,company_id,' . $company_id . ',deleted_at,NULL',