Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserRepo {
- findById($id) {
- ...
- }
- save($user) {
- if (!$user instanceof User) {
- // исключение
- }
- }
- }
- $user = $this->userRepo->findById($id);
- echo $user->name;
- $user = $this->userRepo->findById($id);
- $user->name = 'fail';
- $user->save();
- $data = [данные нового юзера];
- // создать
- $user = $this->userRepo->save($data);
- // обновить
- $user = $this->userRepo->save($data, $model);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement