add id card to profile #23
@@ -16,7 +16,7 @@ class AuthorizationService
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->url = config('fib.authorization.url');
|
$this->url = config('fib.authorization.url');
|
||||||
$this->channelName = '';
|
$this->channelName = 'fib_authorization';
|
||||||
$this->inputParameters = [
|
$this->inputParameters = [
|
||||||
'client_id' => config('fib.authorization.client_id'),
|
'client_id' => config('fib.authorization.client_id'),
|
||||||
'client_secret' => config('fib.authorization.client_secret'),
|
'client_secret' => config('fib.authorization.client_secret'),
|
||||||
@@ -51,7 +51,6 @@ class AuthorizationService
|
|||||||
{
|
{
|
||||||
return Http::asForm()
|
return Http::asForm()
|
||||||
->throw()
|
->throw()
|
||||||
->withoutVerifying()
|
|
||||||
->post($this->url, $this->inputParameters)
|
->post($this->url, $this->inputParameters)
|
||||||
->json();
|
->json();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\User\Controllers;
|
namespace App\User\Controllers;
|
||||||
|
|
||||||
|
use App\Facades\File\FileFacade;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\City;
|
use App\Models\City;
|
||||||
use App\Models\Province;
|
use App\Models\Province;
|
||||||
@@ -11,7 +12,9 @@ use App\User\Requests\Profile\EditRequest;
|
|||||||
use App\User\Resources\UserResource;
|
use App\User\Resources\UserResource;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class ProfileController extends Controller
|
class ProfileController extends Controller
|
||||||
{
|
{
|
||||||
@@ -22,27 +25,40 @@ class ProfileController extends Controller
|
|||||||
return $this->successResponse(new UserResource(Auth::user()));
|
return $this->successResponse(new UserResource(Auth::user()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
public function edit(EditRequest $request): JsonResponse
|
public function edit(EditRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$province = Province::query()->find($request->province_id);
|
$province = Province::query()->find($request->province_id);
|
||||||
$city = City::query()->find($request->city_id);
|
$city = City::query()->find($request->city_id);
|
||||||
|
|
||||||
$user->update([
|
DB::transaction(function () use ($user, $province, $city, $request) {
|
||||||
'first_name' => $request->first_name,
|
if ($user->kyc_status == 0)
|
||||||
'last_name' => $request->last_name,
|
{
|
||||||
'national_id' => $request->national_id,
|
$user->documents()->create([
|
||||||
'address' => $request->address,
|
'title' => 'id_card',
|
||||||
'postal_code' => $request->postal_code,
|
'url' => FileFacade::save($request->file('id_card'), "{$user->id}/"),
|
||||||
'phone_number' => $request->phone_number,
|
]);
|
||||||
'province_id' => $province->id,
|
}
|
||||||
'province_name' => $province->name,
|
|
||||||
'city_id' => $city->id,
|
$user->update([
|
||||||
'city_name' => $city->name,
|
'first_name' => $request->first_name,
|
||||||
'birth_date' => $request->birth_date,
|
'last_name' => $request->last_name,
|
||||||
'email' => $request->email,
|
'national_id' => $request->national_id,
|
||||||
'kyc_status' => 1,
|
'address' => $request->address,
|
||||||
]);
|
'postal_code' => $request->postal_code,
|
||||||
|
'phone_number' => $request->phone_number,
|
||||||
|
'province_id' => $province->id,
|
||||||
|
'province_name' => $province->name,
|
||||||
|
'city_id' => $city->id,
|
||||||
|
'city_name' => $city->name,
|
||||||
|
'birth_date' => $request->birth_date,
|
||||||
|
'email' => $request->email,
|
||||||
|
'kyc_status' => 1,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,7 @@ class EditRequest extends FormRequest
|
|||||||
return [
|
return [
|
||||||
'first_name' => 'required|string|max:255',
|
'first_name' => 'required|string|max:255',
|
||||||
'last_name' => 'required|string|max:255',
|
'last_name' => 'required|string|max:255',
|
||||||
'national_id' => [
|
'national_id' => [Rule::prohibitedIf($user->kyc_status == 1), 'string',],
|
||||||
Rule::prohibitedIf($user->kyc_status == 1), 'string',
|
|
||||||
],
|
|
||||||
'email' => 'required|email|max:255',
|
'email' => 'required|email|max:255',
|
||||||
'address' => 'required|string',
|
'address' => 'required|string',
|
||||||
'postal_code' => 'required|string',
|
'postal_code' => 'required|string',
|
||||||
@@ -40,6 +38,7 @@ class EditRequest extends FormRequest
|
|||||||
'province_id' => 'required|exists:provinces,id',
|
'province_id' => 'required|exists:provinces,id',
|
||||||
'city_id' => 'required|exists:cities,id',
|
'city_id' => 'required|exists:cities,id',
|
||||||
'birth_date' => 'required|date',
|
'birth_date' => 'required|date',
|
||||||
|
'id_card' => [Rule::prohibitedIf($user->kyc_status == 1), 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,18 @@ class UserResource extends JsonResource
|
|||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'username' => $this->username,
|
'username' => $this->username,
|
||||||
'email' => $this->email,
|
'email' => $this->email,
|
||||||
|
'first_name' => $this->first_name,
|
||||||
|
'last_name' => $this->last_name,
|
||||||
|
'national_id' => $this->national_id,
|
||||||
|
'address' => $this->address,
|
||||||
|
'postal_code' => $this->postal_code,
|
||||||
|
'phone_number' => $this->phone_number,
|
||||||
|
'province_id' => $this->provonce_id,
|
||||||
|
'province_name' => $this->province_name,
|
||||||
|
'city_id' => $this->city_id,
|
||||||
|
'city_name' => $this->city_name,
|
||||||
|
'birth_date' => $this->birth_date,
|
||||||
|
'kyc_status' => $this->kyc_status,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,12 @@ return [
|
|||||||
'path' => storage_path('logs/laravel.log'),
|
'path' => storage_path('logs/laravel.log'),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'fib_authorization' => [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/fib/authorization.log'),
|
||||||
|
'level' => 'error',
|
||||||
|
],
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ return new class extends Migration
|
|||||||
$table->dateTime('expires_in');
|
$table->dateTime('expires_in');
|
||||||
$table->foreignId('payment_id')->constrained('payments');
|
$table->foreignId('payment_id')->constrained('payments');
|
||||||
$table->string('payment_track_id');
|
$table->string('payment_track_id');
|
||||||
$table->foreignId('gateway_id')->constrained('gateways');
|
$table->foreignId('user_gateway_id')->constrained('user_gateways');
|
||||||
$table->integer('status');
|
$table->integer('status');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user