close #1989 Fixed: Vendor logo not saved

This commit is contained in:
Cüneyt Şentürk 2021-04-20 21:44:20 +03:00
parent 34632a0152
commit 0c485c990a
2 changed files with 16 additions and 0 deletions

View File

@ -6,6 +6,7 @@ use App\Abstracts\Job;
use App\Models\Auth\User;
use App\Models\Auth\Role;
use App\Models\Common\Contact;
use Illuminate\Support\Str;
class CreateContact extends Job
{
@ -36,6 +37,13 @@ class CreateContact extends Job
}
$this->contact = Contact::create($this->request->all());
// Upload logo
if ($this->request->file('logo')) {
$media = $this->getMedia($this->request->file('logo'), Str::plural($this->contact->type));
$this->contact->attachMedia($media, 'logo');
}
});
return $this->contact;

View File

@ -6,6 +6,7 @@ use App\Abstracts\Job;
use App\Models\Auth\Role;
use App\Models\Auth\User;
use App\Models\Common\Contact;
use Illuminate\Support\Str;
class UpdateContact extends Job
{
@ -39,6 +40,13 @@ class UpdateContact extends Job
$this->createUser();
}
// Upload logo
if ($this->request->file('logo')) {
$media = $this->getMedia($this->request->file('logo'), Str::plural($this->contact->type));
$this->contact->attachMedia($media, 'logo');
}
$this->contact->update($this->request->all());
});