PATH:
home
/
rwabteecom
/
project_11
/
app
/
Http
/
Controllers
/
Dashboard
/
Design
/
Editing: SocialIconsController.php
<?php namespace App\Http\Controllers\Dashboard\Design; use App\Enums\OnboardingEnum; use App\Http\Controllers\Controller; use App\Models\DomainSocial; use App\Services\Link\LinkServices; use App\Services\Socials\DomainSocialServices; use Illuminate\Http\Request; use Exception; use Log; class SocialIconsController extends Controller { public function __construct( private readonly DomainSocialServices $socialIconsServices, private readonly LinkServices $linkServices ) { } public function store(Request $request) { try { $domain = auth()->user()->domain; $icon = $this->socialIconsServices->store($domain, $request); } catch (Exception $exception) { Log::error($exception->getMessage()); return $this->sendFailedResponse($exception->getMessage()); } return $this->sendSuccessResponse(['id' => $icon->id], __('Updated successfully')); } public function update(Request $request) { try { $requestData = $request->json()->all(); $domain = auth()->user()->domain; if($requestData['type'] == 'status'){ $this->socialIconsServices->updateStatus($domain, $request); }else if($request->type == 'update'){ $this->socialIconsServices->updateIcon($domain, $request); } } catch (Exception $exception) { Log::error($exception->getMessage()); return $this->sendFailedResponse($exception->getMessage()); } return $this->sendSuccessResponse([], __('Updated successfully')); } public function delete(Request $request) { try { $domain = auth()->user()->domain; $this->socialIconsServices->store($domain, $request); } catch (Exception $exception) { Log::error($exception->getMessage()); return $this->sendFailedResponse($exception->getMessage()); } return $this->sendSuccessResponse([], __('Updated successfully')); } public function order(Request $request) { try { $domain = auth()->user()->domain; $this->socialIconsServices->order($domain, $request); } catch (Exception $exception) { Log::error($exception->getMessage()); return $this->sendFailedResponse($exception->getMessage()); } return $this->sendSuccessResponse([], __('Updated successfully')); } public function saveSocials(Request $request) { try { $domain = auth()->user()->domain; $baseCounter = $domain->socialIcons->count(); foreach($request->links as $id => $link) { $baseCounter++; if($link){ DomainSocial::query()->create([ "domain_id" => $domain->id, "social_icon_id"=> $id, "link" => $link, "order" => $baseCounter ]); } } $this->linkServices->store($request); } catch (Exception $exception) { Log::error($exception->getMessage()); return $this->sendFailedResponse($exception->getMessage()); } skipBoardingStep(OnboardingEnum::PROFILE_DETAILS); return redirect()->route('dashboard.onboarding'); } }
SAVE
CANCEL