1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\cxinv\model;
- class Action extends Base
- {
- //设置字段信息
- protected $schema = [
- 'id' =>'bigint',//
- 'menuid' =>'bigint',//菜单id
- 'action_code' =>'varchar',//功能编号
- 'status' =>'int',//状态 0 禁用1启用
- 'is_del' =>'tinyint',//是否删除 0 否1 是
- 'addtime' =>'datetime',//
- 'updatetime' =>'datetime',//
- ];
- public function MenuInfo(){
- return $this->belongsTo(AdminMenu::class,'menuid')->bind(['menu_name','pid']);
- }
- public function ActionInfo(){
- return $this->belongsTo(ActionList::class,'action_code','action_code')->bind(['action_name']);
- }
- public static function GetAction($action){
- $list= self::with(['MenuInfo','ActionInfo'])->where(['id'=>$action])->select();
- if($list->isEmpty())return[];
- $temp=[];
- foreach ($list as $item){
- $tempC=[
- 'parent_id'=>$item->pid,
- 'parent_name'=>'',
- 'menu_name'=>$item->menu_name,
- 'menu_id'=>$item->menuid,
- 'action_name'=>$item->action_name,
- 'action_id'=>$item->id,
- 'action_code'=>$item->action_code,
- ];
- if($item->pid>0){
- $tempC['parent_name'] = AdminMenu::where(['id'=>$item->pid,'is_del'=>0])->value('menu_name','');
- }
- $temp[]=$tempC;
- }
- return $temp;
- }
- }
|