<?php


namespace App\Utility;


use App\AdminRole;
use Illuminate\Http\Request;

class Helper
{
    function sub_mobile($mobile = ''){
        $mobile_asterisk = substr($mobile,0,4)."****".substr($mobile,8,3);
        return $mobile_asterisk;
    }

    function privacy(Request $request){
        $admin = $request->session()->get('admin');
        //获取当前管理员角色
        $roles = $admin->roles;
        $role        = AdminRole::findOrFail($roles[0]->id);
        $flag = false;
        $role->permissions->each(function ($rPermission) use (&$flag) {
            if ($rPermission->id == 15) {
                return $flag = true;
            }
        });
        return $flag;
    }
}
