Skip to content

Commit ea96952

Browse files
edit_signup_add_teamcrud
1 parent 3a57946 commit ea96952

12 files changed

+600
-39
lines changed

Codelink.postman_collection.json

+248-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"formdata": [
2828
{
2929
"key": "name",
30-
"value": "Eman Elhelaly",
30+
"value": "eman",
3131
"type": "text"
3232
},
3333
{
@@ -232,7 +232,7 @@
232232
},
233233
{
234234
"key": "code",
235-
"value": "4118",
235+
"value": "4738",
236236
"type": "text"
237237
}
238238
]
@@ -357,6 +357,252 @@
357357
}
358358
},
359359
"response": []
360+
},
361+
{
362+
"name": "teams",
363+
"request": {
364+
"auth": {
365+
"type": "bearer",
366+
"bearer": [
367+
{
368+
"key": "token",
369+
"value": "1|nE0Zk8Jnx76AuPGuLkH0cVuG04GtJ3t4OZs9Qejw",
370+
"type": "string"
371+
}
372+
]
373+
},
374+
"method": "GET",
375+
"header": [
376+
{
377+
"key": "Accept",
378+
"value": "application/json",
379+
"type": "text"
380+
},
381+
{
382+
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
383+
"key": "Authorization",
384+
"value": "application/json",
385+
"type": "text"
386+
}
387+
],
388+
"url": {
389+
"raw": "http://localhost:8000/api/teams",
390+
"protocol": "http",
391+
"host": [
392+
"localhost"
393+
],
394+
"port": "8000",
395+
"path": [
396+
"api",
397+
"teams"
398+
]
399+
}
400+
},
401+
"response": []
402+
},
403+
{
404+
"name": "teams/show",
405+
"request": {
406+
"auth": {
407+
"type": "bearer",
408+
"bearer": [
409+
{
410+
"key": "token",
411+
"value": "1|nE0Zk8Jnx76AuPGuLkH0cVuG04GtJ3t4OZs9Qejw",
412+
"type": "string"
413+
}
414+
]
415+
},
416+
"method": "GET",
417+
"header": [
418+
{
419+
"key": "Accept",
420+
"value": "application/json",
421+
"type": "text"
422+
}
423+
],
424+
"url": {
425+
"raw": "http://localhost:8000/api/teams/show/7",
426+
"protocol": "http",
427+
"host": [
428+
"localhost"
429+
],
430+
"port": "8000",
431+
"path": [
432+
"api",
433+
"teams",
434+
"show",
435+
"7"
436+
]
437+
}
438+
},
439+
"response": []
440+
},
441+
{
442+
"name": "teams/create",
443+
"request": {
444+
"auth": {
445+
"type": "bearer",
446+
"bearer": [
447+
{
448+
"key": "token",
449+
"value": "3|uDhinqMDqXk2Sz8pEGqh2h5KQYU61gN2kENAOePq",
450+
"type": "string"
451+
}
452+
]
453+
},
454+
"method": "POST",
455+
"header": [
456+
{
457+
"key": "Accept",
458+
"value": "application/json",
459+
"type": "text"
460+
},
461+
{
462+
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
463+
"key": "Authorization",
464+
"value": "application/json",
465+
"type": "text"
466+
}
467+
],
468+
"body": {
469+
"mode": "formdata",
470+
"formdata": [
471+
{
472+
"key": "name",
473+
"value": "sala",
474+
"type": "text"
475+
},
476+
{
477+
"key": "description",
478+
"value": "salaaaaah",
479+
"type": "text"
480+
}
481+
]
482+
},
483+
"url": {
484+
"raw": "http://localhost:8000/api/teams/create",
485+
"protocol": "http",
486+
"host": [
487+
"localhost"
488+
],
489+
"port": "8000",
490+
"path": [
491+
"api",
492+
"teams",
493+
"create"
494+
]
495+
}
496+
},
497+
"response": []
498+
},
499+
{
500+
"name": "teams/edit",
501+
"request": {
502+
"auth": {
503+
"type": "bearer",
504+
"bearer": [
505+
{
506+
"key": "token",
507+
"value": "3|uDhinqMDqXk2Sz8pEGqh2h5KQYU61gN2kENAOePq",
508+
"type": "string"
509+
}
510+
]
511+
},
512+
"method": "POST",
513+
"header": [
514+
{
515+
"key": "Accept",
516+
"value": "application/json",
517+
"type": "text"
518+
},
519+
{
520+
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
521+
"key": "Authorization",
522+
"value": "application/json",
523+
"type": "text"
524+
}
525+
],
526+
"body": {
527+
"mode": "formdata",
528+
"formdata": [
529+
{
530+
"key": "name",
531+
"value": "bbb",
532+
"type": "text"
533+
},
534+
{
535+
"key": "description",
536+
"value": "hiiiiiiiicc",
537+
"type": "text",
538+
"disabled": true
539+
}
540+
]
541+
},
542+
"url": {
543+
"raw": "http://localhost:8000/api/teams/edit/9",
544+
"protocol": "http",
545+
"host": [
546+
"localhost"
547+
],
548+
"port": "8000",
549+
"path": [
550+
"api",
551+
"teams",
552+
"edit",
553+
"9"
554+
]
555+
}
556+
},
557+
"response": []
558+
},
559+
{
560+
"name": "teams/delete",
561+
"request": {
562+
"auth": {
563+
"type": "bearer",
564+
"bearer": [
565+
{
566+
"key": "token",
567+
"value": "1|nE0Zk8Jnx76AuPGuLkH0cVuG04GtJ3t4OZs9Qejw",
568+
"type": "string"
569+
}
570+
]
571+
},
572+
"method": "POST",
573+
"header": [
574+
{
575+
"key": "Accept",
576+
"value": "application/json",
577+
"type": "text"
578+
},
579+
{
580+
"warning": "This is a duplicate header and will be overridden by the Authorization header generated by Postman.",
581+
"key": "Authorization",
582+
"value": "application/json",
583+
"type": "text"
584+
}
585+
],
586+
"body": {
587+
"mode": "formdata",
588+
"formdata": []
589+
},
590+
"url": {
591+
"raw": "http://localhost:8000/api/teams/delete/5",
592+
"protocol": "http",
593+
"host": [
594+
"localhost"
595+
],
596+
"port": "8000",
597+
"path": [
598+
"api",
599+
"teams",
600+
"delete",
601+
"5"
602+
]
603+
}
604+
},
605+
"response": []
360606
}
361607
]
362608
}

app/Http/Controllers/Api/Auth/EmailVerificationController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ public function verifyEmail(CodeRequest $request)
6363
$userData = $user->only($user->responseFields());
6464
$userData['token'] = $token;
6565

66-
return ApiTrait::data(['user' => $userData], "Correct Code", 200);
66+
return ApiTrait::data(['user' => $userData], "Email address has been verified successfully", 200);
6767
}
6868
}

app/Http/Controllers/Api/Auth/SignupController.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,42 @@
22

33
namespace App\Http\Controllers\Api\Auth;
44

5-
use App\Models\User;
65
use App\Traits\ApiTrait;
76
use Illuminate\Http\Request;
87
use App\Http\Controllers\Controller;
9-
use Illuminate\Support\Facades\Hash;
108
use App\Http\Requests\Auth\SignupRequest;
9+
use Illuminate\Support\Facades\Hash;
10+
use App\Mail\VerificationCode;
11+
use App\Models\User;
12+
use Illuminate\Support\Facades\Mail;
1113

1214
class SignupController extends Controller
1315
{
14-
/**
15-
* Handle the incoming request.
16-
*
17-
* @param \Illuminate\Http\Request $request
18-
* @return \Illuminate\Http\Response
19-
*/
16+
use ApiTrait;
17+
2018
public function __invoke(SignupRequest $request)
2119
{
2220
$data = $request->safe()->except('password_confirmation', 'password');
2321
$data['password'] = Hash::make($request->password);
2422

2523
try {
2624
$user = User::create($data);
25+
26+
// Send verification code
27+
$code = rand(1000, 9999); // Generate a 4-digit code
28+
$user->code = $code;
29+
$user->code_expired_at = now()->addMinutes(config('auth.code_timeout'));
30+
$user->save();
31+
32+
Mail::to($user)->send(new VerificationCode($user));
2733
} catch (\Exception $e) {
2834
return ApiTrait::errorMessage([], "Something went wrong", 500);
2935
}
3036

3137
$userData = $user->only($user->responseFields());
3238

33-
return response()->json([
34-
'result' => true,
35-
'message' => "Registration Successful, now verify your email",
36-
'data' => [
37-
'user' => $userData,
38-
],
39-
'errors' => [],
40-
], 201);
39+
return $this->data(['user' => $userData], 'Registration Successful, now verify your email', 200);
4140
}
4241
}
4342

43+

0 commit comments

Comments
 (0)