【发布时间】:2016-04-21 07:40:08
【问题描述】:
我已经这样实现了我的控制器:
class PayamAPIController extends Controller
{
const THESIS = \App\Models\Thesis;
public function getOffers($offerable)
{
// does not work
$entities = self::THESIS::where('user_id',\Auth::id())->get();
}
}
这是我的控制器类的 simplifield 版本。
问题是我无法通过常量访问Thesis 模型。
PayamAPIController.php 第 27 行中的 FatalErrorException:语法错误,意外 '::' (T_PAAMAYIM_NEKUDOTAYIM)
我需要将我的模型存储在常量或变量中,并在控制器方法中使用它们
【问题讨论】:
-
随便
THESIS::where()->get() -
我需要引用常量并从那里获取模型