-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add endpoints for fetching and updating user data, add validati… #6
Changes from 2 commits
6d616ed
afff290
d1e7bb2
be9cd8e
825e276
30aa0aa
2b1ae38
a081a7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class UserUpdateRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
*/ | ||
public function authorize(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'name' => 'string|min:2|max:30|regex:/^[a-zA-ZÀ-ž\s\'-]+$/', | ||
'last_name' => 'string|min:2|max:30|regex:/^[a-zA-ZÀ-ž\s\'-]+$/', | ||
'email' => 'email|max:255', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dodaj tutaj również unique |
||
'phone_number' => 'string|regex:/^\+?\d{9,15}$/', | ||
'voivodship' => 'string|min:1|max:30', | ||
'city' => 'string|min:1|max:30', | ||
'zip_code' => 'string|regex:/^\d{2}-\d{3}$/', | ||
'street' => 'string|min:1|max:30', | ||
'house_number' => 'string|regex:/^\d+[a-zA-Z]?$/', | ||
|
||
'card_first_name' => 'string|min:2|max:30|regex:/^[a-zA-ZÀ-ž\s\'-]+$/', | ||
'card_last_name' => 'string|min:2|max:30|regex:/^[a-zA-ZÀ-ž\s\'-]+$/', | ||
'card_number' => 'string|regex:/^\d{16}$/', | ||
'card_expiry_date' => 'string|regex:/^\d{2}\/\d{2}$/', | ||
'card_cvv' => 'string|regex:/^\d{3,4}$/', | ||
]; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class UserResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray(Request $request): array | ||
{ | ||
return parent::toArray($request); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,24 @@ public function up(): void | |
Schema::create('users', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->string('last_name')->nullable(); | ||
$table->string('email')->unique(); | ||
$table->string('role')->nullable(); | ||
$table->string('phone_number')->nullable(); | ||
$table->string('voivodship')->nullable(); | ||
$table->string('city')->nullable(); | ||
$table->string('zip_code')->nullable(); | ||
$table->string('street')->nullable(); | ||
$table->string('house_number')->nullable(); | ||
$table->timestamp('email_verified_at')->nullable(); | ||
$table->string('password'); | ||
|
||
$table->string('card_first_name')->nullable(); | ||
$table->string('card_last_name')->nullable(); | ||
$table->string('card_number')->nullable(); | ||
$table->string('card_expiry_date')->nullable(); | ||
$table->string('card_cvv')->nullable(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Przenieść do oddzielenej tabeli z relacją 1:1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Zadbać o odpowiednie przechowywanie danych, ich zwracanie oraz szyfrowanie |
||
|
||
$table->rememberToken(); | ||
$table->timestamps(); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Użycie struktury stworzonej w Course