Adjust watermark permissions and transparency
This commit is contained in:
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Http\Resources\Tenant;
|
||||
|
||||
use App\Models\WatermarkSetting;
|
||||
use App\Services\Packages\PackageLimitEvaluator;
|
||||
use App\Support\TenantMemberPermissions;
|
||||
use App\Support\WatermarkConfigResolver;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Http\Resources\MissingValue;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
use function app;
|
||||
@@ -47,6 +50,8 @@ class EventResource extends JsonResource
|
||||
$limitEvaluator = app()->make(PackageLimitEvaluator::class);
|
||||
}
|
||||
|
||||
$settings['watermark_removal_allowed'] = WatermarkConfigResolver::determineRemovalAllowed($this->resource);
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
@@ -108,6 +113,27 @@ class EventResource extends JsonResource
|
||||
$watermark = Arr::get($settings, 'watermark');
|
||||
$base = config('watermark.base', []);
|
||||
$base = is_array($base) ? $base : [];
|
||||
$baseSetting = null;
|
||||
|
||||
if (class_exists(WatermarkSetting::class) && Schema::hasTable('watermark_settings')) {
|
||||
try {
|
||||
$baseSetting = WatermarkSetting::query()->first();
|
||||
} catch (\Throwable) {
|
||||
$baseSetting = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($baseSetting) {
|
||||
$base = array_merge($base, array_filter([
|
||||
'asset' => $baseSetting->asset,
|
||||
'position' => $baseSetting->position,
|
||||
'opacity' => $baseSetting->opacity,
|
||||
'scale' => $baseSetting->scale,
|
||||
'padding' => $baseSetting->padding,
|
||||
'offset_x' => $baseSetting->offset_x,
|
||||
'offset_y' => $baseSetting->offset_y,
|
||||
], static fn ($value) => $value !== null));
|
||||
}
|
||||
|
||||
if (! is_array($watermark)) {
|
||||
$watermark = [];
|
||||
|
||||
Reference in New Issue
Block a user