Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace App\Repositories;
- use App\Product;
- <?php
- class UserRepository implements UserRepositoryInterface {
- public function getAllUsers()
- {
- return User::all();
- }
- public function getUserById($id)
- {
- return User::find($id);
- }
- public function createOrUpdate($id = null)
- {
- if(is_null($id)) {
- // create after validation
- $user = new User;
- $user->name = 'Sheikh Heera'
- $user->email = 'me@yahoo.com';
- $user->password = '123456'
- return $user->save();
- }
- else {
- // update after validation
- $user = User::find($id);
- $user->name = 'Sheikh Heera'
- $user->email = 'me@yahoo.com';
- $user->password = '123456'
- return $user->save();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement