belongsToMany('App\Role','authority_role','id_authority','id_role'); } function getNameFilteredAttribute(){ preg_match('#(.*)(_[0-9]*?$)#',$this['name'],$arr); if($arr){ $id=str_replace('_','',$arr[2]); $owner = Owner::find($id); if($owner){return "{$arr[1]}({$owner['name']})";} } return $this['name']; } function getOwnerIdAttribute(){ preg_match('#_([0-9]*?)$#',$this['name'],$arr); if(count($arr)>1&&$arr[1]){ return $arr[1]; } return ''; } }