首页 > 其他分享 >DcatAdmin 多对多关联是,multipleSelect 报错 Array to string conversion

DcatAdmin 多对多关联是,multipleSelect 报错 Array to string conversion

时间:2024-05-26 11:23:12浏览次数:13  
标签:conversion relatedModel string 关联 报错 multipleSelect id

class Activity extends Model
{
    // 定义关联关系
    public function adminUsers()
    {
        // 中间表
        $pivotTable = 'activity_admin_users';
        // 关联模型类名
        $relatedModel = AdminUser::class;
        return $this->belongsToMany($relatedModel, $pivotTable, 'activity_id', 'admin_user_id')->withTimestamps();
    }
}
$form->multipleSelect('adminUsers')
    ->options(AdminUser::pluck('username', 'id'))
    ->customFormat(function ($v) {
        // 二维数组转一维 ,主要就是这段
        return array_column($v, 'id');
    });

标签:conversion,relatedModel,string,关联,报错,multipleSelect,id
From: https://www.cnblogs.com/fengchi/p/18213425

相关文章

  • 【从0到1学习Redis】数据类型 — String
    首先要先启动好服务,使用redis-cli进入到客户端。自增、自减和相加减操作自增1INCR自减1DECR步长i+=INCRBY字符串范围range截取GETRANGE替换SETRANGE是否存在设置过期时间setex(setwithexpire)不存在时再设置(在分布式锁中常常会使用!)setnx(set......
  • String常用方法(4)
    publicStringtrim()------去掉字符前后的空格publicStringtoUperCase()------将小写转成大写publicbooleanendWith(Stringstr)------判断字符串是否以str结尾publicstaticvoidmain(String[]args){Stringcontent2="HelloWorld";//7.trim();去掉字符串前后的......
  • MySQL报错注入之Xpath报错&floor函数报错
    目录前言Xpath报错注入updatexml()函数extractvalue()函数floor函数报错count与groupby的虚拟表总结前言报错注入的使用场景一般是页面无法正常回显数据库查询的内容,但是会详细显示查询过程的错误信息。如果连错误信息都没有,那就是盲注了。报错注入的原理就是将子查询语句查询......
  • String常用方法(2)
    publicchar[]toCharArray()------将字符串转换成数组。pubulicintindexOf(Stringstr)------查找str首次出现的下标,存在,则返回该下标;不存在,则返回-1。publicintlastIndexOf(Stringstr)------查找字符串在当前字符串中最后一次出现的下标索引。publicstaticvoidmain......
  • bash: _get_comp_words_by_ref: command not found 报错
    没有安装补全的包错误信息bash:_get_comp_words_by_ref:commandnotfound表明你的shell中可能存在补全功能的问题。通常,这种错误发生在你的系统上未正确安装或配置bash-completion包时。这个包提供了kubectl和其他命令行工具所需的补全脚本。为了解决这个问题,你可以......
  • PLSQL启动报错:Initialization error,不能初始化
    1.Oracle客户端的oci.dll是32位的,而PLSQLDeveloper是64位应用程序,所以无法加载oracle精简客户端下载地址,连接2.没有安装正确的VisualStudioRedistributable版本解读:很多人忽略了官网的“安装说明”,里面有重要的一点,就是必须安装VisualStudioRedistributable,这是......
  • String类常用方法
    常用方法:publicintlength()-------返回字符串的长度publiccharcharAt(intindex)-------根据下标获取字符publicbooleancontains(Stringstr)------判断当前字符串是否包含str详细代码:publicclassDemo02{publicstaticvoidmain(String[]args){//字......
  • String方法概述
    String字符串是常量,创建之后不能改变。(不可变性)例:publicclassDemo01{publicstaticvoidmain(String[]args){Stringname="hello";//"hello"常量存储在字符串池中,name="zhangsan";//"zhangsan"赋值给name变量,给字符串赋值时,并没有修改数据,而重......
  • 报错:npm ERR! code CERT_HAS_EXPIREDnpm ERR! errno CERT_HAS_EXPIRED
    目录解决方法1、清除npm缓存 2、禁用SSL3、手动设置npm镜像源一般来说到这里就可以了4、更新npm和Node.js5、更新操作系统6、更新根证书...........................................................................................................................
  • 报错 OpenBLAS blas_thread_init: RLIMIT_NPROC 4096 current, -1 max
    跑whisper报错OpenBLASblas_thread_init:RLIMIT_NPROC4096current,-1maxPython创建大量线程时遇上OpenBLASblas_thread_init报错怎么办?https://www.cnblogs.com/shiyanhe/p/13604707.html解决办法:在shell脚本设置参数即可解决。exportOPENBLAS_NUM_THREADS=2......