PATH:
home
/
rwabteecom
/
project_11
/
app
/
Services
/
Domain
/
Editing: DomainServices.php
<?php namespace App\Services\Domain; use App\Interfaces\ServiceInterface; use App\Models\Domain; use App\Models\DomainTheme; use App\Models\Theme; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Facades\DB; use Str; use Auth; use Illuminate\Support\Arr; use Log; class DomainServices implements ServiceInterface { public function index($active = false) { } public function searchByDomain($domain) { return Domain::query()->where('domain', $domain)->firstOrFail(); } public function findOrFail($id, $active = false, $withTrashed = false) { return Domain::query()->findOrFail($id); } public function findWithoutFail($id, $active = false, $withTrashed = false) { } public function store($request): void { } public function update($id, $request) { } public function destroy($id): void { } public function restore($id): void { } public function updateLogo($domain, $request) { if ($request->remove_logo == '1') { // remove image if ($domain->hasMedia('logo')) { $domain->getFirstMedia('logo')->delete(); } return; } if ($request->hasFile("logo")) { $domain->addMedia($request->logo)->toMediaCollection('logo'); return true; } return false; } public function updateDesign($domain, $request) { $domain->currentTheme()->update([ 'font' => $request->font, 'text_color' => $request->text_color, 'background_style' => $request->background_style, 'layout' => $request->layout, 'background_color' => $request->background_color, 'background_first_color' => $request->background_first_color, 'background_second_color' => $request->background_second_color, 'background_direction' => $request->background_direction, 'button_font' => $request->button_font, 'button_text_weight' => $request->button_text_weight ?? '200', 'button_background' => $request->button_background, 'button_color' => $request->button_color, 'button_transparency' => $request->button_transparency, 'button_border_width' => $request->button_border_width, 'button_border_color' => $request->button_border_color, 'button_border_radius' => $request->button_border_radius, 'button_shadow_xoffset' => $request->button_shadow_xoffset, 'button_shadow_yoffset' => $request->button_shadow_yoffset, 'button_shadow_blur' => $request->button_shadow_blur, 'button_shadow_spread' => $request->button_shadow_spread, 'button_shadow_color' => $request->button_shadow_color, 'button_shadow_transparency' => $request->button_shadow_transparency, 'button_image_radius' => $request->button_image_radius ?? 'circle', 'header_layout' => $request->header_layout ?? 'stacked', 'hide_profile_image' => $request->boolean('hide_profile_image'), 'hide_profile_title' => $request->boolean('hide_profile_title'), 'enable_banner_image' => $request->boolean('enable_banner_image'), 'hide_community' => $request->boolean('hide_community'), 'social_icons_style' => $request->social_icons_style ?? 'icon', 'social_icons_color' => $request->social_icons_color, 'social_icons_position' => $request->social_icons_position ?? 'bottom' ]); $domain->update([ 'site_title' => $request->site_title, 'intro_text' => $request->intro_text, 'location' => $request->location, 'location_link' => $request->location_link, 'hide_branding' => $request->boolean('hide_branding'), ]); } public function uploadBannerImage($domain, $file) { $domain->addMedia($file)->toMediaCollection('banner_image'); } public function uploadBackgroundImage($domain, $file) { $domain->addMedia($file)->toMediaCollection('background_image'); } public function uploadQrImage($domain, $file) { $domain->addMedia($file)->toMediaCollection('qr_image'); } public function updateTheme($domain, $request) { $domain_themes = DomainTheme::where('domain_id', currentDomain()->id)?->first(); if ($request->theme_id) { $theme = Theme::query()->find($request->theme_id); $theme_id = $theme?->id; if ($theme) { $data = Arr::except($theme, ["id", 'updated_at', 'created_at', 'deleted_at', 'status'])->toArray(); $data['domain_id'] = currentDomain()->id; $domain_themes = DomainTheme::where('domain_id', currentDomain()->id)->where('theme_id', $theme_id)->first(); if (!$domain_themes) { $data['theme_id'] = $theme_id; $domain_themes = DomainTheme::create($data); } if(config('app.env') != 'local'){ /* if($theme->banner){ $domain->addMediaFromUrl($theme->banner)->preservingOriginal()->toMediaCollection('banner_image'); } */ /* if($theme->logo){ $domain->addMediaFromUrl($theme->logo)->preservingOriginal()->toMediaCollection('logo'); } */ if($theme->backgroundImg){ $domain->addMediaFromUrl($theme->backgroundImg)->preservingOriginal()->toMediaCollection('background_image'); } } } $domain->update([ 'domain_theme_id' => $domain_themes->id ]); } } public function updateQR($domain, $request) { $domain->update([ 'qr_dot_scale' => $request->qr_dot_scale, 'qr_background_color' => $request->qr_background_color, 'qr_color' => $request->qr_color, 'qr_img_style' => $request->qr_img_style, ]); return $this->getQR($domain); } public function getQR($domain) { $logo = null; if (isset($domain->qr_img_style) || $domain->qr_img_style != "no_image") { if ($domain->qr_img_style == "profile_image") { $logo = auth()->user()->profileImage; } else if ($domain->qr_img_style == "custom_image") { $logo = $domain->qrImg; } } return [ 'text' => env('APP_URL') . '/' . $domain->domain, 'qr_dot_scale' => $domain->qr_dot_scale, 'qr_background_color' => $domain->qr_background_color, 'qr_color' => $domain->qr_color, 'logo' => $logo ]; } }
SAVE
CANCEL