<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;

class pro_pro_access_SINGLE_Controller extends Controller
{
    public $selfName = 'pro_pro_access_SINGLE_Controller';
    public $dashboardName = 'dashboard';

	// GET /pro_pro_access/view/{uid}/ACTION_update
	public function ACTION_update(Request $request, $uid) {
		$record = DB::table('pro_pro_access')->where('uid', $uid)->first();
		if(!$record) {
			$record = DB::table('pro_pro_access')->where('id', $uid)->first();
			if($record) return redirect('/pro_pro_access/view/' . $record->uid . '/ACTION_update');
		}
		return response()->view('admin/pro_pro_access_SINGLE/ACTION_update', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
	}

	// GET /pro_pro_access/view/{uid}/ACTION_reactivate
	public function ACTION_reactivate(Request $request, $uid) {
		$record = DB::table('pro_pro_access')->where('uid', $uid)->first();
		if(!$record) {
			$record = DB::table('pro_pro_access')->where('id', $uid)->first();
			if($record) return redirect('/pro_pro_access/view/' . $record->uid . '/ACTION_reactivate');
		}
		return response()->view('admin/pro_pro_access_SINGLE/ACTION_reactivate', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
	}

	// GET /pro_pro_access/view/{uid}/ACTION_deactivate
	public function ACTION_deactivate(Request $request, $uid) {
		$record = DB::table('pro_pro_access')->where('uid', $uid)->first();
		if(!$record) {
			$record = DB::table('pro_pro_access')->where('id', $uid)->first();
			if($record) return redirect('/pro_pro_access/view/' . $record->uid . '/ACTION_deactivate');
		}
		return response()->view('admin/pro_pro_access_SINGLE/ACTION_deactivate', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
	}

	// GET /pro_pro_access/view/{uid}/SUB_dashboard
	public function SUB_dashboard(Request $request, $uid) {
		$record = DB::table('pro_pro_access')->where('uid', $uid)->first();
		if(!$record) {
			$record = DB::table('pro_pro_access')->where('id', $uid)->first();
			if($record) return redirect('/pro_pro_access/view/' . $record->uid . '/SUB_dashboard');
		}
		return response()->view('admin/pro_pro_access_SINGLE/SUB_dashboard', compact('record'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
	}
}
