Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
registrationController | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
register | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace App\Http\Controllers\Api\user\authentication; |
4 | |
5 | use App\Http\Controllers\Controller; |
6 | use App\Http\Requests\Api\user\createRequest; |
7 | use App\Models\User; |
8 | use App\Traits\response; |
9 | use Illuminate\Http\Request; |
10 | use Illuminate\Support\Facades\Hash; |
11 | use Tymon\JWTAuth\Facades\JWTAuth; |
12 | |
13 | class 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 | } |