2019-10-07 23:17:55 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-10-07 23:17:55 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-10-07 23:17:55 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-10-07 23:17:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Utils\Traits;
|
|
|
|
|
2020-11-04 00:56:29 +01:00
|
|
|
use App\Jobs\Util\UnlinkFile;
|
2019-10-08 00:07:43 +02:00
|
|
|
use App\Jobs\Util\UploadAvatar;
|
2020-11-04 00:56:29 +01:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2019-10-08 00:07:43 +02:00
|
|
|
|
2019-10-07 23:17:55 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class Uploadable.
|
2019-10-07 23:17:55 +02:00
|
|
|
*/
|
|
|
|
trait Uploadable
|
|
|
|
{
|
2020-11-04 00:56:29 +01:00
|
|
|
public function removeLogo($company)
|
|
|
|
{
|
2023-02-22 10:13:50 +01:00
|
|
|
(new UnlinkFile(config('filesystems.default'), $company?->settings?->company_logo))->handle();
|
2020-11-04 00:56:29 +01:00
|
|
|
}
|
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
public function uploadLogo($file, $company, $entity)
|
|
|
|
{
|
|
|
|
if ($file) {
|
2022-06-24 13:15:14 +02:00
|
|
|
$path = (new UploadAvatar($file, $company->company_key))->handle();
|
2019-12-30 22:59:12 +01:00
|
|
|
if ($path) {
|
2019-10-07 23:17:55 +02:00
|
|
|
$settings = $entity->settings;
|
2020-02-27 00:32:44 +01:00
|
|
|
$settings->company_logo = $path;
|
2019-10-07 23:17:55 +02:00
|
|
|
$entity->settings = $settings;
|
|
|
|
$entity->save();
|
|
|
|
}
|
|
|
|
}
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
|
|
|
}
|