2 回答

TA貢獻1848條經驗 獲得超10個贊
我認為您缺少 coor() 關系中的鍵。您沒有使用 autodealers 表中的 id 作為外鍵,因此您需要在關系中進行設置。
public function coor(){ return $this->belongsTo('App\plz', 'id', 'plz_id'); }

TA貢獻1874條經驗 獲得超12個贊
updated_at當我使用 Tinker 時,我注意到,如果沒有,就無法保存對象created_at。Tinker 拋出這個 SQL 錯誤:
照亮/數據庫/QueryException 并顯示消息 'SQLSTATE[42S22]:未找到列:1054 '字段列表'中的未知列 'updated_at'(SQL:插入 ( , , )plzs值id( updated_at33611 created_at, 2020-07-02 11:18: 12, 2020-07-02 11:18:12))'
所以我在表中添加了時間戳:
public function up()
{
Schema::create('plzs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->text("Ort");
$table->decimal('Latitude', 10, 8);
$table->decimal('Longitude', 11, 8);
$table->timestamps();
});
}
和
public function up()
{
Schema::create('autodealers', function (Blueprint $table) {
$table->bigIncrements('id');
//connect to the plzs table via reference to plz table
$table->unsignedBigInteger('plz_id');
$table->text("H?ndler");
//index for any foreign key
$table->index('plz_id');
$table->timestamps();
});
}
在 mySQL 中updated_at,created_at每個表的 , 列必須另外設置 CURRENT-TIME 標準,以便在導入 csv 數據期間填充updated_at和列。created_at
- 2 回答
- 0 關注
- 192 瀏覽
添加回答
舉報