<?php 
namespace App\Models;

use Illuminate\Database\Eloquent\Model;


class Adminmenumanage extends Model {

	protected $table = 'adminmenumanage';

	public $timestamps = false;

	public static function getmenuname($id){
		$name = Adminmenu::find($id);
		if($name){
			return $name->menuname;
		}
		return "";
	}

	public static function getmenudetails($id){
		return $name = Adminmenu::find($id);
	}

	public static function hasSubmenu($id){
		return Adminmenumanage::where('parentId', $id)->where('status', 'active')->count();
	}

	public static function getSubmenu($id){
		return Adminmenumanage::where('parentId', $id)->where('status', 'active')->get();
	}

	public static function getMainMenuID($id){
		$check = Adminmenumanage::where('menuId', $id)->first();
		
		if($check && $check->parentId != 0){
			return $check->parentId;
		}else{
			return $check->menuId;
		}
	}
	
}
