<?php

namespace App\Http\Controllers;

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

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

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

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