/
home
/
corsairdevelopme
/
public_html
/
amplivo-console
/
app
/
Http
/
Controllers
/
Upload File
HOME
<?php namespace App\Http\Controllers; use App\Models\SiteConfiguration; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Str; class Google2FASetting extends Controller { function __construct() { $this->middleware("permission:google-2fa-setting-view", ['only' => ['memberGoogle2FASettingIndex']]); $this->middleware("permission:google-2fa-setting-edit", ['only' => ['updateMemberGoogle2FASetting']]); } public function memberGoogle2FASettingIndex() { $mandatoryMemberGoogle2fa = json_decode(getSiteSettings('mandatory_member_google_2fa')); return view('backend.member-google-2fa-settings', compact('mandatoryMemberGoogle2fa')); } public function updateMemberGoogle2FASetting(Request $request) { $mandatoryMemberGoogle2fa = $request->input('mandatory_member_google_2fa', null); $mandatoryMemberGoogle2faValue = ($mandatoryMemberGoogle2fa) ? json_encode($mandatoryMemberGoogle2fa) : null; $old_record = SiteConfiguration::where(['key' => 'mandatory_member_google_2fa'])->first(); $old_value = $old_record->value ?? null; if (($old_record['value'] ?? null) != $mandatoryMemberGoogle2faValue) { SiteConfiguration::updateOrCreate(['key' => 'mandatory_member_google_2fa'], ['value' => $mandatoryMemberGoogle2faValue]); $oldModules = $old_value ? implode(',', json_decode($old_value, true)) : 'none'; $newModules = $mandatoryMemberGoogle2fa ? implode(',', $mandatoryMemberGoogle2fa) : 'none'; saveLog(Auth::user()->details->first_name . " " . Auth::user()->details->last_name . ' has updated setting ' . ucwords(Str::replace("_", " ", 'mandatory_member_google_2fa')) . ' ' . ($oldModules ?? 'none') . ' to ' . ($newModules ?? '') . ' ', $old_record, [], 'updated'); } return response()->json([ 'status' => 'success', 'message' => 'Mandatory google 2FA for member setting updated successfully!', ]); } }