mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 19:51:09 -04:00
fixed uploaded attachment not removed
This commit is contained in:
committed by
Mohit Panjwani
parent
f34dac9d3f
commit
8ba84f68c7
@ -126,14 +126,14 @@ class Expense extends Model implements HasMedia
|
||||
{
|
||||
foreach (explode(' ', $search) as $term) {
|
||||
$query->whereHas('category', function ($query) use ($term) {
|
||||
$query->where('name', 'LIKE', '%'.$term.'%');
|
||||
$query->where('name', 'LIKE', '%' . $term . '%');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function scopeWhereNotes($query, $search)
|
||||
{
|
||||
$query->where('notes', 'LIKE', '%'.$search.'%');
|
||||
$query->where('notes', 'LIKE', '%' . $search . '%');
|
||||
}
|
||||
|
||||
public function scopeWhereCategory($query, $categoryId)
|
||||
@ -188,9 +188,9 @@ class Expense extends Model implements HasMedia
|
||||
{
|
||||
foreach (explode(' ', $search) as $term) {
|
||||
$query->whereHas('category', function ($query) use ($term) {
|
||||
$query->where('name', 'LIKE', '%'.$term.'%');
|
||||
$query->where('name', 'LIKE', '%' . $term . '%');
|
||||
})
|
||||
->orWhere('notes', 'LIKE', '%'.$term.'%');
|
||||
->orWhere('notes', 'LIKE', '%' . $term . '%');
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,6 +262,9 @@ class Expense extends Model implements HasMedia
|
||||
ExchangeRateLog::addExchangeRateLog($this);
|
||||
}
|
||||
|
||||
if (isset($request->is_attachment_receipt_removed) && (bool) $request->is_attachment_receipt_removed) {
|
||||
$this->clearMediaCollection('receipts');
|
||||
}
|
||||
if ($request->hasFile('attachment_receipt')) {
|
||||
$this->clearMediaCollection('receipts');
|
||||
$this->addMediaFromRequest('attachment_receipt')->toMediaCollection('receipts');
|
||||
|
||||
Reference in New Issue
Block a user