<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use View, DB, File, Auth, Route;
use App\Http\Controllers\Controller;
use Intervention\Image\Facades\Image;
use Illuminate\Support\Facades\Input;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Validator;
use Illuminate\Routing\Controller as BaseController;

class BackendController extends BaseController {

	public function __construct(Request $request) {
	    $user = Auth::user();
	    if (isset($user->name) && $user->name == 'demo') {
	    	$getRoute = Route::getCurrentRoute()->getActionName();
	    	if (
	    		$getRoute == 'App\Http\Controllers\AdminController@addnewmedia' || 
	    		$getRoute == 'App\Http\Controllers\AdminController@editmedia' || 
	    		$getRoute == 'App\Http\Controllers\AdminController@delete' || 
	    		$getRoute == 'App\Http\Controllers\AdminController@updateabout' ||
	    		$getRoute == 'App\Http\Controllers\AdminController@postsettings' ||
	    		$getRoute == 'App\Http\Controllers\AdminController@addcategory' ||
	    		$getRoute == 'App\Http\Controllers\AdminController@editcategory'
	    		)
	    	{
				$request->session()->flash('flash_message', "Sorry, demo account doesn't support this function.");
				$request->session()->flash('flash_type', 'alert-danger');
				//return redirect('admin');
				//return response()->view('admin.adminpage', ['media'=>$media]);
				// return redirect('/admin')->with('status', "Sorry, demo account doesn't support this function.");
				// exit();
	    		header('Location: http://'.$_SERVER["HTTP_HOST"]."/admin?message=error");
	    		exit();
	    	}
	    }
	}
}