<?php

namespace App\Http\Controllers;

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

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

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

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

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

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