【问题标题】:Schema getColumnType nort working架构 getColumnType 不起作用
【发布时间】:2017-11-21 08:03:44
【问题描述】:

试图在我的 json(laravel 项目)中获取 Column 类型,但不工作?,谁能看看有什么问题?

protected function getType()
    {
      return Schema::getColumnType($this->builder->getModel()->getTable() , $this->getUpdatableColums());
    }
    enter code here
    protected function getRecords(Request $request)
    {
      //   return $this->builder->limit($request->limit)->orderBy('id', 'asc')->get($this->getDisplayableColums());
      return $this->builder
            ->limit($request->limit)
            ->orderBy('id', 'asc')
            ->get($this->getDisplayableColums())
            ->getType();
    }

【问题讨论】:

    标签: mysql json laravel-5 schema


    【解决方案1】:

    在您的 getType 方法中,您似乎传递的是数组而不是字符串

    protected function getType()
    {
      return Schema::getColumnType($this->builder->getModel()->getTable() , $this->getUpdatableColums());
    }
    

    laravel 5.5 文档说“string getColumnType(string $table, string $column)”

    https://laravel.com/api/5.5/Illuminate/Database/Schema/Builder.html#method_getColumnType

    您也许可以更改您的 getType 方法以获取列名。并在你的代码中做一个循环

    foreach ($this->getUpdatableColumns() as $column) {
        $this->getType($column);
    }
    

    【讨论】:

      猜你喜欢
      • 2015-11-18
      • 1970-01-01
      • 1970-01-01
      • 2017-05-25
      • 2017-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多