| Current Path : /var/www/html/aipa/backend/models/frontendmenu/ |
| Current File : /var/www/html/aipa/backend/models/frontendmenu/FrontendMenu.php |
<?php
namespace backend\models\frontendmenu;
use Yii;
/**
* This is the model class for table "frontend_menu".
*
* @property integer $menu_id
* @property string $menu_name
* @property integer $menu_order
* @property integer $page_id
* @property string $menu_link
* @property integer $menu_type
* @property integer $menu_parent_id
*/
class FrontendMenu extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'frontend_menu';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['menu_name', 'menu_link'], 'string'],
[['menu_order', 'page_id', 'menu_parent_id', 'site_id', 'menu_button_type', 'menu_type'], 'integer'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'menu_id' => 'Menu ID',
'menu_name' => 'Menu Name',
'menu_order' => 'Menu Order',
'page_id' => 'Menu Page',
'menu_link' => 'Menu Link',
'menu_type' => 'Menu Type',
'menu_button_type' => 'Menu Button Type',
'menu_parent_id' => 'Menu Parent ID',
'site_id'=> 'Site ID'
];
}
public static function dropdown($site_id, $parent_id=0){
static $dropdown;
if($dropdown == null){
$dropdown[0] = "Without parent menu";
$models = static::find()->where(['site_id'=>$site_id])->orderBy(['menu_name'=>SORT_DESC])->all();
foreach($models as $model){
$dropdown[$model->menu_id] = $model->menu_name;
}
}
return $dropdown;
}
}