mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
fixed uploaded attachment not removed
This commit is contained in:
committed by
Mohit Panjwani
parent
f34dac9d3f
commit
8ba84f68c7
@ -71,6 +71,9 @@ class CompanyController extends Controller
|
||||
|
||||
$data = json_decode($request->company_logo);
|
||||
|
||||
if (isset($request->is_company_logo_removed) && (bool) $request->is_company_logo_removed) {
|
||||
$company->clearMediaCollection('logo');
|
||||
}
|
||||
if ($data) {
|
||||
$company = Company::find($request->header('company'));
|
||||
|
||||
@ -98,6 +101,9 @@ class CompanyController extends Controller
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if (isset($request->is_admin_avatar_removed) && (bool) $request->is_admin_avatar_removed) {
|
||||
$user->clearMediaCollection('admin_avatar');
|
||||
}
|
||||
if ($user && $request->hasFile('admin_avatar')) {
|
||||
$user->clearMediaCollection('admin_avatar');
|
||||
|
||||
|
||||
@ -17,6 +17,9 @@ class ProfileController extends Controller
|
||||
|
||||
$customer->update($request->validated());
|
||||
|
||||
if (isset($request->is_customer_avatar_removed) && (bool) $request->is_customer_avatar_removed) {
|
||||
$customer->clearMediaCollection('customer_avatar');
|
||||
}
|
||||
if ($customer && $request->hasFile('customer_avatar')) {
|
||||
$customer->clearMediaCollection('customer_avatar');
|
||||
|
||||
|
||||
@ -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