我浏览了这篇文章... Laravel - 使用保留字命名模型
但这并没有提供定义关系的解决方案。
我有一个模型名称Class.php
,我必须将它与 Student & ClassAllocation 联系起来
这是我在 Student.php 中定义的关系:
/**
* Check the Class allocated to Student
*
*@return void
*/
public function class()
{
return $this->belongsToMany('App\Class', 'class_allocations');
}
我已经尝试了所有方法,现在我不想更改我的模型名称。我该如何进行这项工作?我在修补程序上不断收到此错误:
PHP 错误:语法错误,意外的“类”(T_CLASS),第 7 行 /home/vagrant/Homestead/app/app/Class.php 中的预期标识符(T_STRING)