@@ -95,6 +95,10 @@ public function resetModel()
95
95
$ this ->makeModel ();
96
96
}
97
97
98
+ public function lists ($ column , $ key = null )
99
+ {
100
+ $ this ->applyConditions ();
101
+ }
98
102
99
103
/**
100
104
* 根据主键查询
@@ -356,9 +360,10 @@ public function paginate($columns = ['*'], $limit = 0)
356
360
*/
357
361
public function create (array $ attributes )
358
362
{
359
- $ result = $ this ->model ->create ($ attributes );
363
+ $ model = $ this ->model ->newInstance ($ attributes );
364
+ $ model ->save ();
360
365
$ this ->resetModel ();
361
- return $ result ;
366
+ return $ model ;
362
367
}
363
368
364
369
/**
@@ -386,10 +391,13 @@ public function createBatch(array $attributes)
386
391
*/
387
392
public function updateById (array $ attributes , int $ id )
388
393
{
389
- $ model = $ this ->model ->find ($ id );
390
- $ result = $ model ->update ($ attributes );
394
+ $ model = $ this ->model ->findOrFail ($ id );
395
+
396
+ $ model ->fill ($ attributes );
397
+ $ model ->save ();
398
+
391
399
$ this ->resetModel ();
392
- return $ result ;
400
+ return $ model ;
393
401
}
394
402
395
403
/**
@@ -498,8 +506,8 @@ public function updateBatch(array $multipleData = []): bool
498
506
public function deleteById (int $ id )
499
507
{
500
508
$ model = $ this ->find ($ id );
501
- $ result = $ model ->delete ();
502
509
$ this ->resetModel ();
510
+ $ result = $ model ->delete ();
503
511
return $ result ;
504
512
505
513
}
@@ -885,7 +893,7 @@ public function commit()
885
893
DB ::commit ();
886
894
}
887
895
888
-
896
+
889
897
/**
890
898
* 打印sql语句
891
899
* @param Closure $callback
@@ -904,4 +912,14 @@ public function getQuerySql(Closure $callback, string $tableName = '')
904
912
}
905
913
}
906
914
915
+ /**
916
+ * @param $method
917
+ * @param $arguments
918
+ * @return mixed
919
+ */
920
+ public function __call ($ method , $ arguments )
921
+ {
922
+ return call_user_func_array ([$ this ->model , $ method ], $ arguments );
923
+ }
924
+
907
925
}
0 commit comments