app($ classModel)-> getQuery()!= app($ classModel)-> query()或app($ classModel)-> getQuery()!= $ classModel :: query()

时间:2019-08-29 03:38:44

标签: php laravel-5 eloquent builder

为什么函数 getQuery()与模型中的 query()不同?

app($classModel)->getQuery() != app($classModel)->query() or app($classModel)->getQuery() != $classModel::query()

在此示例中,model1与model2不同,为什么?

$model1 = app($class)->query()->first();
=> App\Models\User {#3389
 id: 1,
 name: "laisha88",
 first_name: "Jackson",
 last_name: "McKenzie"
}
$model2 = app($class)->getQuery()->first();
=> {#3369
 +"id": 1,
 +"name": "laisha88",
 +"first_name": "Jackson",
 +"last_name": "McKenzie"
}

0 个答案:

没有答案