| Current Path : /var/www/html/dyna-crm/models/ |
| Current File : /var/www/html/dyna-crm/models/MenuAccess.php |
<?php
namespace app\models;
use app\models\ParamList;
use Yii;
/**
* This is the model class for table "menu_access".
*
* @property int $id
* @property int $menu_id
* @property string $user_role
* @property string $created_dt
* @property int $created_by
*/
class MenuAccess extends \yii\db\ActiveRecord {
/**
* {@inheritdoc}
*/
public static function tableName() {
return 'menu_access';
}
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['menu_id', 'user_role'], 'required'],
[['menu_id', 'created_by'], 'integer'],
[['created_dt'], 'safe'],
[['user_role'], 'string', 'max' => 10],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels() {
return [
'id' => 'ID',
'menu_id' => 'Menu ID',
'user_role' => 'User Role',
'created_dt' => 'Created Dt',
'created_by' => 'Created By',
];
}
public function getuseraccess($menu_id) {
$ParamList = new ParamList();
$output = '';
$model = static::find()->where(['menu_id' => $menu_id])->orderBy(['id' => SORT_ASC])->all();
if (!empty($model)) {
foreach ($model as $row) {
$output.= '<span class="kt-badge kt-badge--info kt-badge--inline kt-badge--rounded">' . $ParamList->getlabel(2, $row->user_role) . '</span> ';
}
}
return $output;
}
public function checkmenuaccess($menu_id, $user_role) {
$output = 0;
$model = static::find()->where(['menu_id' => $menu_id, 'user_role' => $user_role])->all();
if (!empty($model)) {
$output = 1;
}
return $output;
}
}