Compare commits

...

2 Commits

6 changed files with 53 additions and 21 deletions

View File

@@ -16,7 +16,7 @@ class AuthorizationService
public function __construct()
{
$this->url = config('fib.authorization.url');
$this->channelName = '';
$this->channelName = 'fib_authorization';
$this->inputParameters = [
'client_id' => config('fib.authorization.client_id'),
'client_secret' => config('fib.authorization.client_secret'),
@@ -51,7 +51,6 @@ class AuthorizationService
{
return Http::asForm()
->throw()
->withoutVerifying()
->post($this->url, $this->inputParameters)
->json();
}

View File

@@ -2,6 +2,7 @@
namespace App\User\Controllers;
use App\Facades\File\FileFacade;
use App\Http\Controllers\Controller;
use App\Models\City;
use App\Models\Province;
@@ -11,7 +12,9 @@ use App\User\Requests\Profile\EditRequest;
use App\User\Resources\UserResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Throwable;
class ProfileController extends Controller
{
@@ -22,27 +25,40 @@ class ProfileController extends Controller
return $this->successResponse(new UserResource(Auth::user()));
}
/**
* @throws Throwable
*/
public function edit(EditRequest $request): JsonResponse
{
$user = Auth::user();
$province = Province::query()->find($request->province_id);
$city = City::query()->find($request->city_id);
$user->update([
'first_name' => $request->first_name,
'last_name' => $request->last_name,
'national_id' => $request->national_id,
'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,
]);
DB::transaction(function () use ($user, $province, $city, $request) {
if ($user->kyc_status == 0)
{
$user->documents()->create([
'title' => 'id_card',
'url' => FileFacade::save($request->file('id_card'), "{$user->id}/"),
]);
}
$user->update([
'first_name' => $request->first_name,
'last_name' => $request->last_name,
'national_id' => $request->national_id,
'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();
}

View File

@@ -30,9 +30,7 @@ class EditRequest extends FormRequest
return [
'first_name' => 'required|string|max:255',
'last_name' => 'required|string|max:255',
'national_id' => [
Rule::prohibitedIf($user->kyc_status == 1), 'string',
],
'national_id' => [Rule::prohibitedIf($user->kyc_status == 1), 'string',],
'email' => 'required|email|max:255',
'address' => 'required|string',
'postal_code' => 'required|string',
@@ -40,6 +38,7 @@ class EditRequest extends FormRequest
'province_id' => 'required|exists:provinces,id',
'city_id' => 'required|exists:cities,id',
'birth_date' => 'required|date',
'id_card' => [Rule::prohibitedIf($user->kyc_status == 1), 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048']
];
}
}

View File

@@ -18,6 +18,18 @@ class UserResource extends JsonResource
'id' => $this->id,
'username' => $this->username,
'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,
];
}
}

View File

@@ -127,6 +127,12 @@ return [
'path' => storage_path('logs/laravel.log'),
],
'fib_authorization' => [
'driver' => 'single',
'path' => storage_path('logs/fib/authorization.log'),
'level' => 'error',
],
],
];

View File

@@ -21,7 +21,7 @@ return new class extends Migration
$table->dateTime('expires_in');
$table->foreignId('payment_id')->constrained('payments');
$table->string('payment_track_id');
$table->foreignId('gateway_id')->constrained('gateways');
$table->foreignId('user_gateway_id')->constrained('user_gateways');
$table->integer('status');
$table->timestamps();
});