Merge pull request #3327 from CihanSenturk/fix-update-attachment-remove-issue
Fixed api update attachment issue
This commit is contained in:
commit
d6c9083b80
|
|
@ -34,7 +34,9 @@ class UpdateUser extends Job implements ShouldUpdate
|
|||
$media = $this->getMedia($this->request->file('picture'), 'users');
|
||||
|
||||
$this->model->attachMedia($media, 'picture');
|
||||
} elseif (! $this->request->file('picture') && $this->model->picture) {
|
||||
} elseif ($this->request->isNotApi() && ! $this->request->file('picture') && $this->model->picture) {
|
||||
$this->deleteMediaModel($this->model, 'picture', $this->request);
|
||||
} elseif ($this->request->isApi() && $this->request->has('remove_picture') && $this->model->picture) {
|
||||
$this->deleteMediaModel($this->model, 'picture', $this->request);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate
|
|||
{
|
||||
use Currencies;
|
||||
|
||||
protected Transaction $transaction;
|
||||
|
||||
public function __construct(Document $model, Transaction $transaction, $request)
|
||||
{
|
||||
$this->model = $model;
|
||||
|
|
@ -39,9 +41,15 @@ class UpdateBankingDocumentTransaction extends Job implements ShouldUpdate
|
|||
|
||||
// Upload attachment
|
||||
if ($this->request->file('attachment')) {
|
||||
$this->deleteMediaModel($this->transaction, 'attachment', $this->request);
|
||||
|
||||
$media = $this->getMedia($this->request->file('attachment'), 'transactions');
|
||||
|
||||
$this->transaction->attachMedia($media, 'attachment');
|
||||
} elseif ($this->request->isNotApi() && ! $this->request->file('attachment') && $this->transaction->attachment) {
|
||||
$this->deleteMediaModel($this->transaction, 'attachment', $this->request);
|
||||
} elseif ($this->request->isApi() && $this->request->has('remove_attachment') && $this->transaction->attachment) {
|
||||
$this->deleteMediaModel($this->transaction, 'attachment', $this->request);
|
||||
}
|
||||
|
||||
$this->model->save();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ class UpdateTransaction extends Job implements ShouldUpdate
|
|||
|
||||
$this->model->attachMedia($media, 'attachment');
|
||||
}
|
||||
} elseif (! $this->request->file('attachment') && $this->model->attachment) {
|
||||
} elseif ($this->request->isNotApi() && ! $this->request->file('attachment') && $this->model->attachment) {
|
||||
$this->deleteMediaModel($this->model, 'attachment', $this->request);
|
||||
} elseif ($this->request->isApi() && $this->request->has('remove_attachment') && $this->model->attachment) {
|
||||
$this->deleteMediaModel($this->model, 'attachment', $this->request);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ class UpdateTransfer extends Job implements ShouldUpdate
|
|||
|
||||
$this->model->attachMedia($media, 'attachment');
|
||||
}
|
||||
} elseif (! $this->request->file('attachment') && $this->model->attachment) {
|
||||
} elseif ($this->request->isNotApi() && ! $this->request->file('attachment') && $this->model->attachment) {
|
||||
$this->deleteMediaModel($this->model, 'attachment', $this->request);
|
||||
} elseif ($this->request->isApi() && $this->request->has('remove_attachment') && $this->model->attachment) {
|
||||
$this->deleteMediaModel($this->model, 'attachment', $this->request);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,14 @@ class UpdateContact extends Job implements ShouldUpdate
|
|||
|
||||
// Upload logo
|
||||
if ($this->request->file('logo')) {
|
||||
$this->deleteMediaModel($this->model, 'logo', $this->request);
|
||||
|
||||
$media = $this->getMedia($this->request->file('logo'), Str::plural($this->model->type));
|
||||
|
||||
$this->model->attachMedia($media, 'logo');
|
||||
} elseif (! $this->request->file('logo') && $this->model->logo) {
|
||||
} elseif ($this->request->isNotApi() && ! $this->request->file('logo') && $this->model->logo) {
|
||||
$this->deleteMediaModel($this->model, 'logo', $this->request);
|
||||
} elseif ($this->request->isApi() && $this->request->has('remove_logo') && $this->model->logo) {
|
||||
$this->deleteMediaModel($this->model, 'logo', $this->request);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,15 @@ class UpdateItem extends Job implements ShouldUpdate
|
|||
|
||||
// Upload picture
|
||||
if ($this->request->file('picture')) {
|
||||
$this->deleteMediaModel($this->model, 'picture', $this->request);
|
||||
|
||||
$media = $this->getMedia($this->request->file('picture'), 'items');
|
||||
|
||||
$this->model->attachMedia($media, 'picture');
|
||||
} elseif ($this->request->isNotApi() && ! $this->request->file('picture') && $this->model->picture) {
|
||||
$this->deleteMediaModel($this->model, 'picture', $this->request);
|
||||
} elseif ($this->request->isApi() && $this->request->has('remove_picture') && $this->model->picture) {
|
||||
$this->deleteMediaModel($this->model, 'picture', $this->request);
|
||||
}
|
||||
|
||||
$this->deleteRelationships($this->model, ['taxes']);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ class UpdateDocument extends Job implements ShouldUpdate
|
|||
|
||||
$this->model->attachMedia($media, 'attachment');
|
||||
}
|
||||
} elseif (! $this->request->file('attachment') && $this->model->attachment) {
|
||||
} elseif ($this->request->isNotApi() && ! $this->request->file('attachment') && $this->model->attachment) {
|
||||
$this->deleteMediaModel($this->model, 'attachment', $this->request);
|
||||
} elseif ($this->request->isApi() && $this->request->has('remove_attachment') && $this->model->attachment) {
|
||||
$this->deleteMediaModel($this->model, 'attachment', $this->request);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue