Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/rentpix.corals.io/Corals/core/User/Http/Controllers/API/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/rentpix.corals.io/Corals/core/User/Http/Controllers/API/ProfileController.php
<?php

namespace Corals\User\Http\Controllers\API;

use Corals\Foundation\Http\Controllers\APIBaseController;
use Corals\User\Http\Requests\ProfileRequest;
use Corals\User\Services\ProfileService;
use Corals\User\Transformers\API\UserPresenter;
use Illuminate\Http\Request;

class ProfileController extends APIBaseController
{
    protected $profileService;

    /**
     * ProfileController constructor.
     *
     * @param  ProfileService  $profileService
     *
     * @throws \Exception
     */
    public function __construct(ProfileService $profileService)
    {
        $this->profileService = $profileService;
        $this->profileService->setPresenter(new UserPresenter());

        parent::__construct();
    }

    /**
     * @OA\Get (
     * path="/api/v1/profile",
     * description="You can get the details of user who login by this link",
     * summary="User Profile",
     * tags={"Authentication"},
     *      @OA\Response(
     *          response=200,
     *          description="Success",
     *          @OA\JsonContent(
     *               @OA\Property(property="status", type="string", example="success"),
     *               @OA\Property(property="message", type="string", example=""),
     *               @OA\Property(property="data", type="object",
     *               example={
     *                      "id": "2",
     *                      "full_name": "Corals Member",
     *                      "name": "Corals",
     *                      "last_name": "Member",
     *                      "email": "[email protected]",
     *                      "confirmed": true,
     *                      "roles": {
     *                      "name": "member",
     *                      "label": "Member"
     *                      },
     *                      "job_title": "Ads Coordinator",
     *                      "picture": "http://rental360-api.test/assets/corals/images/avatars/avatar_2.png",
     *                      "picture_thumb": "http://rental360-api.test/assets/corals/images/avatars/avatar_2.png",
     *                      "about": "-",
     *                      "phone_country_code": "-",
     *                      "phone_number": "-",
     *                      "address": "-",
     *                      "integration_id": "-",
     *                      "gateway": "-",
     *                      "card_brand": "-",
     *                      "card_last_four": "-",
     *                      "payment_method_token": "-",
     *                      "created_at": "10 Nov, 2022",
     *                      "updated_at": "10 Nov, 2022",
     *                      "authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIzIiwianRpIjoiZjI0ZDc2ZmU5NDQwNWJjNjgwYmJmNGIyOTAyMzFlM2I3ODYyMWI3N2RkZTE2ZDZmN2JhZWM0OWIzYzQ3OWFhN2VkNGYyZmJmYmRjYzBhMzIiLCJpYXQiOjE2NjgzMjM3NzEuNTg4Nzg4LCJuYmYiOjE2NjgzMjM3NzEuNTg4NzkxLCJleHAiOjE2OTk4NTk3NzEuNTUzNDE2LCJzdWIiOiIyIiwic2NvcGVzIjpbXX0.GJwrQnm8YLTiXrzpGcd0e9Vli3NMWK2-PVUO5O_QJAMmgRwSnvQU-GQvnyuWLSCL7iSimvFAXMzIohrkz6F1y_YN2gC8GLHEITg2yjSGZPHg9m5S9O8BSgf9x7hsqHAK2KYAVkvLUfyBcxBnNlkacdg3spUntY_GWEqsevCKw6MnsF9s4Q1rzeOgC_0FCnTZ7Ee9HOgIhzocft4Gd_M3ZVPslnA8DMIgUE119VbmOzMpErUKTeSlHkCFgari6tEA6lOxc2x62VHd_6UdaYSteZ-hlDnkg769eanRS_pV8TkFI4SSNZ37mBfYuH6l0UVVetFDZi3ps52je0Mg2z3bueRfa3AFENIi-Ik2pjQtKV_OpeL-yWbOIOdX9a3As8JQHKDrPefxG5KsgixGjoHOAc_kHTYVkGv-EOhyhLs7spWKgaylXRiZidXVYOczi8Q95yrlA2Ar2BcybvIbtx8T6lOp-7tte5NOTP0eCaLhcMmgWIdOQq2amSFHi-XfgtwxCLC1Pdb18HJZHT735WxhgYXyS1M1sHJsFfBbMw8YBm-xFqxDeUXm-PyqYrOs2uYibPeC4kFCWZtW2ljJMbcTi9_Dfgdeq22BQ_57yRhqKNC4AOg2o3JiRgz_YR6wBmgyRzoukmnwwAd7CUuQ2HUW7GvI8Imopjyorsl3yGJha2E",
     *                      "expires_at": "2023-11-13 07:16:11"
     *                      }
     *                  ),
     *              ),
     *      ),
     *      @OA\Response(
     *      response=401,
     *      description="Unauthenticated",
     *      @OA\JsonContent(
     *          @OA\Property(property="message", type="string", example="Unauthenticated."),
     *          ),
     *      ),
     * )
     */
    public function getProfileDetails(Request $request)
    {
        try {
            return apiResponse($this->profileService->getModelDetails(user()));
        } catch (\Exception $exception) {
            return apiExceptionResponse($exception);
        }
    }

    public function update(ProfileRequest $request)
    {
        try {
            $this->profileService->setModel(user());

            $data = $this->profileService->getRequestData($request);

            $user = $this->profileService->updateProfile($data);

            $this->profileService->handleUserProfileImage($request);

            return apiResponse($this->profileService->getModelDetails(), trans('Corals::messages.success.updated', ['item' => $user->name]));
        } catch (\Exception $exception) {
            return apiExceptionResponse($exception);
        }
    }

    public function setPassword(Request $request)
    {
        $this->validate($request, [
            'password' => 'required|confirmed|max:191|min:6',
        ]);

        try {
            $this->profileService->setModel(user());

            $this->profileService->setPassword($request->get('password'));

            return apiResponse([], trans('Corals::messages.success.updated', ['item' => trans('User::attributes.user.password')]));
        } catch (\Exception $exception) {
            return apiExceptionResponse($exception);
        }
    }
}

Spamworldpro Mini