<?php

namespace App\Http\Controllers;

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

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

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

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

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

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