【问题标题】:Laravel NOVA without a primary key makes an error没有主键的 Laravel NOVA 会出错
【发布时间】:2019-02-28 11:59:50
【问题描述】:

我有一个无法更改的数据库。当其中一个表没有主键时。这是表格的模块:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
//////////////////////////////////////////////
class t_hendtl extends Model
{
    //
    //protected $primaryKey = 'hen_num';

    protected $table = 't_hendtl';

    public $timestamps = false;  

    public $incrementing = false;

    protected $primaryKey = null;


}

在 nova 方面,我只是不使用 ID 字段。看起来是这样的:

public function fields(Request $request)


 {
        return [
            //ID::make()->sortable(),
            Text::make('Inv number', 'hen_num'),
            Text::make('Inv type', 'hen_type'),
        ];
    }

但是我得到了这个错误:

SQLSTATE[42000]:[Microsoft][ODBC Driver 13 for SQL Server][SQL Server] An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not alowed. Chane the alias to a valid name. (SQL:select top 26*from[t_hendtl]order by [t_hendtl].[] desc).

你有什么建议?

【问题讨论】:

    标签: laravel laravel-nova


    【解决方案1】:

    我终于在表格中添加了一列,尽管它是其他软件正在使用的表格。否则就不行了

    【讨论】:

      猜你喜欢
      • 2019-01-29
      • 2019-05-21
      • 2020-02-16
      • 1970-01-01
      • 2019-10-29
      • 2021-08-13
      • 2019-04-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多