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->dispatch(new CreateDocumentItemsAndTotals($this->document, $this->request));
|
||||||
|
|
||||||
$this->document->paid_amount = $this->document->paid;
|
$this->document->paid_amount = $this->document->paid;
|
||||||
|
|
||||||
event(new PaidAmountCalculated($this->document));
|
event(new PaidAmountCalculated($this->document));
|
||||||
|
|
||||||
if ($this->document->paid_amount > 0) {
|
if ($this->document->paid_amount > 0) {
|
||||||
|
@ -3,11 +3,15 @@
|
|||||||
namespace App\Listeners\Document;
|
namespace App\Listeners\Document;
|
||||||
|
|
||||||
use App\Events\Document\DocumentCreated as Event;
|
use App\Events\Document\DocumentCreated as Event;
|
||||||
|
use App\Models\Common\Company;
|
||||||
use App\Traits\Documents;
|
use App\Traits\Documents;
|
||||||
|
use App\Traits\Uploads;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class SettingFieldCreated
|
class SettingFieldCreated
|
||||||
{
|
{
|
||||||
use Documents;
|
use Documents, Uploads;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the event.
|
* Handle the event.
|
||||||
@ -18,6 +22,7 @@ class SettingFieldCreated
|
|||||||
public function handle(Event $event)
|
public function handle(Event $event)
|
||||||
{
|
{
|
||||||
$request = $event->request;
|
$request = $event->request;
|
||||||
|
$document = $event->document;
|
||||||
|
|
||||||
if (!$request->has('setting')) {
|
if (!$request->has('setting')) {
|
||||||
return;
|
return;
|
||||||
@ -28,6 +33,10 @@ class SettingFieldCreated
|
|||||||
|
|
||||||
foreach ($fields as $key => $value) {
|
foreach ($fields as $key => $value) {
|
||||||
if ($key == 'company_logo') {
|
if ($key == 'company_logo') {
|
||||||
|
if (Arr::has($value, 'dropzone')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
setting()->set('company.logo', $value);
|
setting()->set('company.logo', $value);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -38,6 +47,31 @@ class SettingFieldCreated
|
|||||||
setting()->set($real_key, $value);
|
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
|
// Save all settings
|
||||||
setting()->save();
|
setting()->save();
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,15 @@
|
|||||||
namespace App\Listeners\Document;
|
namespace App\Listeners\Document;
|
||||||
|
|
||||||
use App\Events\Document\DocumentUpdated as Event;
|
use App\Events\Document\DocumentUpdated as Event;
|
||||||
|
use App\Models\Common\Company;
|
||||||
|
use App\Traits\Uploads;
|
||||||
use App\Traits\Documents;
|
use App\Traits\Documents;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class SettingFieldUpdated
|
class SettingFieldUpdated
|
||||||
{
|
{
|
||||||
use Documents;
|
use Documents, Uploads;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the event.
|
* Handle the event.
|
||||||
@ -18,6 +22,7 @@ class SettingFieldUpdated
|
|||||||
public function handle(Event $event)
|
public function handle(Event $event)
|
||||||
{
|
{
|
||||||
$request = $event->request;
|
$request = $event->request;
|
||||||
|
$document = $event->document;
|
||||||
|
|
||||||
if (!$request->has('setting')) {
|
if (!$request->has('setting')) {
|
||||||
return;
|
return;
|
||||||
@ -28,6 +33,10 @@ class SettingFieldUpdated
|
|||||||
|
|
||||||
foreach ($fields as $key => $value) {
|
foreach ($fields as $key => $value) {
|
||||||
if ($key == 'company_logo') {
|
if ($key == 'company_logo') {
|
||||||
|
if (Arr::has($value, 'dropzone')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
setting()->set('company.logo', $value);
|
setting()->set('company.logo', $value);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -38,6 +47,31 @@ class SettingFieldUpdated
|
|||||||
setting()->set($real_key, $value);
|
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
|
// Save all settings
|
||||||
setting()->save();
|
setting()->save();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user