laravel - Laravel 雄辩的更新功能
问题描述
在模块化开发中使用 Laravel eloquent。保存效果很好,但更新功能没有像我预期的那样工作。请检查我的编码方法和错误。
use Modules\Projects\Entities\Project;
public function update(Request $request, $id)
{
$project = Modules\Projects\Entities\Project::find($id);
$project->project_name = request('project_name');
$project->save();
}
错误抛出如下:
{
"message": "Class 'Modules\\Projects\\Http\\Controllers\\Modules\\Projects\\Entities\\Project' not found",
"exception": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError",
"file": "D:\\XMAPP\\htdocs\\minidmsapi\\Modules\\Projects\\Http\\Controllers\\ProjectsController.php",
"line": 69,
"trace": [
如何$flight = App\Flight::find(1);
在模块化开发中使用“”?
Laravel 官方文档
解决方案
尝试添加\
之前Modules\Projects\Entities\Project::find($id);
。
喜欢\Modules\Projects\Entities\Project::find($id);
或者您可以直接使用Project::find($id);
,因为您已经使用过命名空间。
推荐阅读
- multithreading - 堆栈溢出并行更新一个 RT 索引
- matlab - 有向矩阵到无向矩阵
- java - 如何从代理服务器后面的 Java 应用程序访问 Microsoft Graph Java API?
- asterisk - atersik waitexten 没有选择 默认
- python - sklearn.tree.DecisionTreeClassifier:获取所有落入叶节点的样本
- python - 'SARIMAXResults' 对象没有属性 '_params_ma
- oracle - ora 00907 缺少右括号创建表
- php - 子文件夹的重写规则
- google-visualization - SyntaxError:JSON.parse:JSON 数据的第 1 行第 1 列出现意外字符 - 但 JSON 验证器指示“有效 json”
- javascript - 以编程方式触发按下