This commit is contained in:
Kekskurse 2021-01-20 21:59:42 +01:00
parent 937357b135
commit 2c8457e60b
3 changed files with 22 additions and 2 deletions

View file

@ -11,6 +11,7 @@ use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect; use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Storage;
class TenantController extends BaseController class TenantController extends BaseController
{ {
@ -64,6 +65,16 @@ class TenantController extends BaseController
]); ]);
$path = $validated["files"][0]->store("watermark/".session("current_tenant_id")); $path = $validated["files"][0]->store("watermark/".session("current_tenant_id"));
$tenant = Tenant::query()->where("id", "=", session("current_tenant_id"))->firstOrFail();
$oldImage = Image::query()->where("id", "=", $tenant->watermark)->first();
if(!is_null($oldImage)) {
Storage::disk($image->driver)->delete($image->path);
$oldImage->deleted_at = date("Y-m-d H:i:s");
$oldImage->saveOrFail();
}
$image = new Image(); $image = new Image();
$image->path = $path; $image->path = $path;
$image->driver = env('FILESYSTEM_DRIVER', 'local'); $image->driver = env('FILESYSTEM_DRIVER', 'local');
@ -73,7 +84,7 @@ class TenantController extends BaseController
$image->typ = "watermark"; $image->typ = "watermark";
$image->saveOrFail(); $image->saveOrFail();
$tenant = Tenant::query()->where("id", "=", session("current_tenant_id"))->firstOrFail();
$tenant->watermark = $image->id; $tenant->watermark = $image->id;
$tenant->saveOrFail(); $tenant->saveOrFail();

View file

@ -74,8 +74,9 @@ class ResizeImage implements ShouldQueue
if($this->size > 500 && !is_null($tenant->watermark)) { if($this->size > 500 && !is_null($tenant->watermark)) {
Log::info("Add Watermark"); Log::info("Add Watermark");
$cacheNameWatermark = "";
$waterMarkImage = Image::query()->where("id", "=", $tenant->watermark)->firstOrFail(); $waterMarkImage = Image::query()->where("id", "=", $tenant->watermark)->firstOrFail();
$cacheNameWatermark = "watermark/".$waterMarkImage->id."_".$waterMarkImage->filename;
$watermarkSource = $this->getImage($tenant, $gallery, $waterMarkImage, $cacheNameWatermark); $watermarkSource = $this->getImage($tenant, $gallery, $waterMarkImage, $cacheNameWatermark);
$watermark = $manager->make($watermarkSource); $watermark = $manager->make($watermarkSource);

View file

@ -97,6 +97,14 @@
apt: apt:
name: php-zip name: php-zip
state: present state: present
- name: Install imagemagick
apt:
name: imagemagick
state: present
- name: Install php-imagick
apt:
name: php-imagick
state: present
- name: Check that the /bin/composer exists - name: Check that the /bin/composer exists
stat: stat:
path: /bin/composer path: /bin/composer