public function register(Request $request)
    {
        $data = $request->only('email', 'password');

        return DB::transaction(function() use ($data) {
            $user = User::create([
                'name' => $data['email'],
                'email' => $data['email'],
                'password' => bcrypt($data['password']),
            ]);

            $user = $this->service->create($user, $data['password']);
            $token = JWTAuth::fromUser($user);

            return response()->json(compact('token'));
        });
    }
public function register(Request $request)
    {
        $data = $request->only('email', 'password');

        return DB::transaction(function() use ($data) {
            $user = User::create([
                'name' => $data['email'],
                'email' => $data['email'],
                'password' => bcrypt($data['password']),
            ]);

            $user = $this->service->create($user, $data['password']);
            $token = JWTAuth::fromUser($user);

            return response()->json(compact('token'));
        });
    }
public function register ( Request $ request ) { $ data = $ request -> only ( 'email' , 'password' ) ; return DB :: transaction ( function ( ) use ( $ data ) { $ user = User :: create ( [ 'name' => $ data [ 'email' ] , 'email' => $ data [ 'email' ] , 'password' => bcrypt ( $ data [ 'password' ] ) , ] ) ; $ user = $ this -> service -> create ( $ user , $ data [ 'password' ] ) ; $ token = JWTAuth :: fromUser ( $ user ) ; return response ( ) -> json ( compact ( 'token' ) ) ; } ) ; }
Register a User

@param  Request $request
@return JSON
Register a User