[英]I uploaded my Laravel 8 project to Cpanel while i got an error
我正在使用 Laravel 8 並將我的項目上傳到 cPanel。 在我的本地服務器中它工作正常但在實時服務器中它顯示錯誤:
語法錯誤,意外的“:”,期待“)”
返回 $this->belongsTo(JournalHead::class, foreignKey: 'journal_head_id');
下面是我的model:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class JournalEditorial extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'journal_head_id',
'editorial_title',
'editorial_author',
'abstract',
'editorial_page_no',
'editorial_pdf_file',
'editorial_doi_link',
];
public function getEditorialHead() {
return $this->belongsTo(JournalHead::class, foreignKey: 'journal_head_id');
}
}
這些是位置 arguments,其中第二個是外鍵,第三個是本地鍵:
return $this->belongsTo(JournalHead::class, 'journal_head_id');
這是 文檔。
不需要在 journal_head_id 之前輸入外鍵。試試這樣:
public function getEditorialHead() {
return $this->belongsTo(JournalHead::class, 'journal_head_id');
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.