<?php

namespace Clevercherry\Backslash4\Traits;

trait checkControllerSecurityAbort
{
	/**
	 * Aborts the controller view is the method exists and it returns false
	 */
	public function checkControllerSecurityAbort($appModel, $route=false)
	{
		if( method_exists(($appModel), 'showOnDashboardMenu')) {
            if(!($appModel)::showOnDashboardMenu())
				if($route===false) {
					abort(404);
				} else {
				    return redirect(route($route));
				}
          }
	}
}
