Repository.php 526 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2017/12/14
  6. * Time: 下午4:05
  7. */
  8. namespace app\frontend\repositories;
  9. abstract class Repository
  10. {
  11. public function __call($name, $arguments)
  12. {
  13. if (method_exists($this->makeModel(), $name)) {
  14. return $this->makeModel()->$name(...$arguments);
  15. }
  16. throw new \Exception('不存在的方法'.$name);
  17. // TODO: Implement __call() method.
  18. }
  19. private function makeModel()
  20. {
  21. return app()->make($this->model());
  22. }
  23. }