Document edit company logo issue solved..
This commit is contained in:
parent
fc6ed02803
commit
6251d09edb
@ -62,6 +62,7 @@ class UpdateDocument extends Job
|
||||
$this->dispatch(new CreateDocumentItemsAndTotals($this->document, $this->request));
|
||||
|
||||
$this->document->paid_amount = $this->document->paid;
|
||||
|
||||
event(new PaidAmountCalculated($this->document));
|
||||
|
||||
if ($this->document->paid_amount > 0) {
|
||||
|
@ -3,11 +3,15 @@
|
||||
namespace App\Listeners\Document;
|
||||
|
||||
use App\Events\Document\DocumentCreated as Event;
|
||||
use App\Models\Common\Company;
|
||||
use App\Traits\Documents;
|
||||
use App\Traits\Uploads;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SettingFieldCreated
|
||||
{
|
||||
use Documents;
|
||||
use Documents, Uploads;
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
@ -18,6 +22,7 @@ class SettingFieldCreated
|
||||
public function handle(Event $event)
|
||||
{
|
||||
$request = $event->request;
|
||||
$document = $event->document;
|
||||
|
||||
if (!$request->has('setting')) {
|
||||
return;
|
||||
@ -28,6 +33,10 @@ class SettingFieldCreated
|
||||
|
||||
foreach ($fields as $key => $value) {
|
||||
if ($key == 'company_logo') {
|
||||
if (Arr::has($value, 'dropzone')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
setting()->set('company.logo', $value);
|
||||
|
||||
continue;
|
||||
@ -38,6 +47,31 @@ class SettingFieldCreated
|
||||
setting()->set($real_key, $value);
|
||||
}
|
||||
|
||||
$files = $request->file('setting', []);
|
||||
|
||||
if ($files) {
|
||||
$company = Company::find($document->company_id);
|
||||
|
||||
foreach ($files as $key => $value) {
|
||||
// Upload attachment
|
||||
$media = $this->getMedia($value, 'settings');
|
||||
|
||||
$company->attachMedia($media, Str::snake($real_key));
|
||||
|
||||
$value = $media->id;
|
||||
|
||||
if ($key == 'company_logo') {
|
||||
setting()->set('company.logo', $value);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$real_key = $type . '.' . $key;
|
||||
|
||||
setting()->set($real_key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// Save all settings
|
||||
setting()->save();
|
||||
}
|
||||
|
@ -3,11 +3,15 @@
|
||||
namespace App\Listeners\Document;
|
||||
|
||||
use App\Events\Document\DocumentUpdated as Event;
|
||||
use App\Models\Common\Company;
|
||||
use App\Traits\Uploads;
|
||||
use App\Traits\Documents;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SettingFieldUpdated
|
||||
{
|
||||
use Documents;
|
||||
use Documents, Uploads;
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
@ -18,6 +22,7 @@ class SettingFieldUpdated
|
||||
public function handle(Event $event)
|
||||
{
|
||||
$request = $event->request;
|
||||
$document = $event->document;
|
||||
|
||||
if (!$request->has('setting')) {
|
||||
return;
|
||||
@ -28,6 +33,10 @@ class SettingFieldUpdated
|
||||
|
||||
foreach ($fields as $key => $value) {
|
||||
if ($key == 'company_logo') {
|
||||
if (Arr::has($value, 'dropzone')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
setting()->set('company.logo', $value);
|
||||
|
||||
continue;
|
||||
@ -38,6 +47,31 @@ class SettingFieldUpdated
|
||||
setting()->set($real_key, $value);
|
||||
}
|
||||
|
||||
$files = $request->file('setting', []);
|
||||
|
||||
if ($files) {
|
||||
$company = Company::find($document->company_id);
|
||||
|
||||
foreach ($files as $key => $value) {
|
||||
// Upload attachment
|
||||
$media = $this->getMedia($value, 'settings');
|
||||
|
||||
$company->attachMedia($media, Str::snake($real_key));
|
||||
|
||||
$value = $media->id;
|
||||
|
||||
if ($key == 'company_logo') {
|
||||
setting()->set('company.logo', $value);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$real_key = $type . '.' . $key;
|
||||
|
||||
setting()->set($real_key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// Save all settings
|
||||
setting()->save();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user