Transaction model and jobs added multiple attachment
This commit is contained in:
parent
4ef70899be
commit
305ff07ee0
@ -37,9 +37,11 @@ class CreateTransaction extends Job
|
|||||||
|
|
||||||
// Upload attachment
|
// Upload attachment
|
||||||
if ($this->request->file('attachment')) {
|
if ($this->request->file('attachment')) {
|
||||||
$media = $this->getMedia($this->request->file('attachment'), 'transactions');
|
foreach ($this->request->file('attachment') as $attachment) {
|
||||||
|
$media = $this->getMedia($attachment, 'transactions');
|
||||||
|
|
||||||
$this->transaction->attachMedia($media, 'attachment');
|
$this->transaction->attachMedia($media, 'attachment');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recurring
|
// Recurring
|
||||||
|
@ -37,9 +37,15 @@ class UpdateTransaction extends Job
|
|||||||
|
|
||||||
// Upload attachment
|
// Upload attachment
|
||||||
if ($this->request->file('attachment')) {
|
if ($this->request->file('attachment')) {
|
||||||
$media = $this->getMedia($this->request->file('attachment'), 'transactions');
|
$this->transaction->delete_attachment();
|
||||||
|
|
||||||
$this->transaction->attachMedia($media, 'attachment');
|
foreach ($this->request->file('attachment') as $attachment) {
|
||||||
|
$media = $this->getMedia($attachment, 'transactions');
|
||||||
|
|
||||||
|
$this->transaction->attachMedia($media, 'attachment');
|
||||||
|
}
|
||||||
|
} elseif (!$this->request->file('attachment') && $this->transaction->attachment) {
|
||||||
|
$this->transaction->delete_attachment();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recurring
|
// Recurring
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Models\Banking;
|
namespace App\Models\Banking;
|
||||||
|
|
||||||
use App\Abstracts\Model;
|
use App\Abstracts\Model;
|
||||||
|
use App\Models\Common\Media as MediaModel;
|
||||||
use App\Models\Setting\Category;
|
use App\Models\Setting\Category;
|
||||||
use App\Scopes\Transaction as Scope;
|
use App\Scopes\Transaction as Scope;
|
||||||
use App\Traits\Currencies;
|
use App\Traits\Currencies;
|
||||||
@ -320,7 +321,16 @@ class Transaction extends Model
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getMedia('attachment')->last();
|
return $this->getMedia('attachment')->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete_attachment()
|
||||||
|
{
|
||||||
|
if ($attachments = $this->attachment) {
|
||||||
|
foreach ($attachments as $file) {
|
||||||
|
MediaModel::where('id', $file->id)->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user