File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
app/Http/Controllers/Traits Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -804,8 +804,13 @@ public function export()
804
804
return $ value ;
805
805
});
806
806
$ fields = $ this ->selectFields ($ this ->exportFields );
807
- $ fields and $ this ->bindModel = $ this ->bindModel ()->select (in_array ($ model ->getKeyName (), $ fields )
808
- ? $ fields : array_merge ([$ model ->getKeyName ()], $ fields ));
807
+ $ primary_key = $ model ->getKeyName ();
808
+ if ($ primary_key && $ fields && (!isset ($ this ->noPrimaryKey ) || !$ this ->noPrimaryKey )){
809
+ $ primary_key1 = $ model ->getTable ().'. ' .$ primary_key ;
810
+ $ has_primary_key = in_array ($ primary_key ,$ fields ) || in_array ($ primary_key1 ,$ fields );
811
+ $ fields = $ has_primary_key ? $ fields : array_merge ([$ primary_key1 ], $ fields );
812
+ }
813
+ $ fields and $ this ->bindModel = $ this ->bindModel ()->select ($ fields );
809
814
//优化导出
810
815
$ model = $ this ->newBindModel ();
811
816
$ primary_key = $ model ->getKeyName ();
You can’t perform that action at this time.
0 commit comments