mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进Relation类
This commit is contained in:
@@ -107,7 +107,7 @@ class Relation
|
|||||||
$result = $this->belongsToManyQuery($relation, $this->middle, $foreignKey, $localKey, $condition)->select();
|
$result = $this->belongsToManyQuery($relation, $this->middle, $foreignKey, $localKey, $condition)->select();
|
||||||
foreach ($result as $set) {
|
foreach ($result as $set) {
|
||||||
$pivot = [];
|
$pivot = [];
|
||||||
foreach ($set->toArray() as $key => $val) {
|
foreach ($set->getData() as $key => $val) {
|
||||||
if (strpos($key, '__')) {
|
if (strpos($key, '__')) {
|
||||||
list($name, $attr) = explode('__', $key, 2);
|
list($name, $attr) = explode('__', $key, 2);
|
||||||
if ('pivot' == $name) {
|
if ('pivot' == $name) {
|
||||||
@@ -308,7 +308,7 @@ class Relation
|
|||||||
protected function match($model, $relation, &$result)
|
protected function match($model, $relation, &$result)
|
||||||
{
|
{
|
||||||
// 重新组装模型数据
|
// 重新组装模型数据
|
||||||
foreach ($result->toArray() as $key => $val) {
|
foreach ($result->getData() as $key => $val) {
|
||||||
if (strpos($key, '__')) {
|
if (strpos($key, '__')) {
|
||||||
list($name, $attr) = explode('__', $key, 2);
|
list($name, $attr) = explode('__', $key, 2);
|
||||||
if ($name == $relation) {
|
if ($name == $relation) {
|
||||||
@@ -369,7 +369,7 @@ class Relation
|
|||||||
$data = [];
|
$data = [];
|
||||||
foreach ($list as $set) {
|
foreach ($list as $set) {
|
||||||
$pivot = [];
|
$pivot = [];
|
||||||
foreach ($set->toArray() as $key => $val) {
|
foreach ($set->getData() as $key => $val) {
|
||||||
if (strpos($key, '__')) {
|
if (strpos($key, '__')) {
|
||||||
list($name, $attr) = explode('__', $key, 2);
|
list($name, $attr) = explode('__', $key, 2);
|
||||||
if ('pivot' == $name) {
|
if ('pivot' == $name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user