<?php

namespace App\Http\Controllers;

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

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

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

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