首页 > 解决方案 > 没有主键的 Laravel NOVA 会出错

问题描述

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

<?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;


}

在新星方面,我只是不使用 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).

你建议做什么?

标签: laravellaravel-nova

解决方案


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


推荐阅读