Action.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\cxinv\model;
  3. class Action extends Base
  4. {
  5. //设置字段信息
  6. protected $schema = [
  7. 'id' =>'bigint',//
  8. 'menuid' =>'bigint',//菜单id
  9. 'action_code' =>'varchar',//功能编号
  10. 'status' =>'int',//状态 0 禁用1启用
  11. 'is_del' =>'tinyint',//是否删除 0 否1 是
  12. 'addtime' =>'datetime',//
  13. 'updatetime' =>'datetime',//
  14. ];
  15. public function MenuInfo(){
  16. return $this->belongsTo(AdminMenu::class,'menuid')->bind(['menu_name','pid']);
  17. }
  18. public function ActionInfo(){
  19. return $this->belongsTo(ActionList::class,'action_code','action_code')->bind(['action_name']);
  20. }
  21. public static function GetAction($action){
  22. $list= self::with(['MenuInfo','ActionInfo'])->where(['id'=>$action])->select();
  23. if($list->isEmpty())return[];
  24. $temp=[];
  25. foreach ($list as $item){
  26. $tempC=[
  27. 'parent_id'=>$item->pid,
  28. 'parent_name'=>'',
  29. 'menu_name'=>$item->menu_name,
  30. 'menu_id'=>$item->menuid,
  31. 'action_name'=>$item->action_name,
  32. 'action_id'=>$item->id,
  33. 'action_code'=>$item->action_code,
  34. ];
  35. if($item->pid>0){
  36. $tempC['parent_name'] = AdminMenu::where(['id'=>$item->pid,'is_del'=>0])->value('menu_name','');
  37. }
  38. $temp[]=$tempC;
  39. }
  40. return $temp;
  41. }
  42. }