Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
registrationController
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 register
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Http\Controllers\Api\user\authentication;
4
5use App\Http\Controllers\Controller;
6use App\Http\Requests\Api\user\createRequest;
7use App\Models\User;
8use App\Traits\response;
9use Illuminate\Http\Request;
10use Illuminate\Support\Facades\Hash;
11use Tymon\JWTAuth\Facades\JWTAuth;
12
13class registrationController extends Controller
14{
15    public function register(createRequest $request){
16        $user = User::create([
17            'username'          => $request->username,
18            'name'              => $request->name,
19            'password'          => Hash::make($request->password),
20        ]);
21
22        //create token
23        $token = JWTAuth::fromUser($user);
24
25        $data = [
26            'user'  => $user,
27            'token' => $token,
28        ];
29
30        return $this->success(trans('api.success'),
31                                200,
32                                'data',
33                                $data);
34    }
35}