Compare commits

...

8 Commits

4 changed files with 50 additions and 8 deletions

View File

@@ -17,7 +17,7 @@ class DocumentationController extends Controller
public function index(Request $request): array public function index(Request $request): array
{ {
return DataTableFacade::run( return DataTableFacade::run(
User::query(), User::query()->where('kyc_status','!=',0),
$request, $request,
allowedFilters: ['*'], allowedFilters: ['*'],
allowedSortings: ['*'], allowedSortings: ['*'],

View File

@@ -14,6 +14,7 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Laravel\Passport\ClientRepository;
use Throwable; use Throwable;
class GatewayManagementController extends Controller class GatewayManagementController extends Controller
@@ -27,7 +28,7 @@ class GatewayManagementController extends Controller
$request, $request,
allowedFilters: ['*'], allowedFilters: ['*'],
allowedSortings: ['*'], allowedSortings: ['*'],
allowedSelects: ['id', 'name', 'domain', 'tax_id', 'bank_name', 'account_holder', 'iban', 'business_type_id', 'business_type_name'], allowedSelects: ['*'],
); );
} }
@@ -38,9 +39,15 @@ class GatewayManagementController extends Controller
{ {
$user = Auth::guard('web')->user(); $user = Auth::guard('web')->user();
$logo = $request->has('logo') ? FileFacade::save($request->file('logo'), "{$user->id}") : null; $logo = $request->hasFile('logo')
? FileFacade::save($request->file('logo'), "{$user->id}")
: null;
$passportClient = DB::transaction(function () use ($user, $logo, $request) {
$clientName = "Gateway {$request->name} - User {$user->id}";
$client = app(ClientRepository::class)->createPasswordGrantClient($clientName, 'users');
DB::transaction(function () use ($user, $logo, $request) {
UserGateway::query()->create([ UserGateway::query()->create([
'user_id' => $user->id, 'user_id' => $user->id,
'username' => $user->username, 'username' => $user->username,
@@ -53,15 +60,20 @@ class GatewayManagementController extends Controller
'business_type_id' => $request->business_type_id, 'business_type_id' => $request->business_type_id,
'business_type_name' => BusinessTypeEnum::name($request->business_type_id), 'business_type_name' => BusinessTypeEnum::name($request->business_type_id),
'logo' => $logo, 'logo' => $logo,
'client_id' => $client->id,
'client_secret' => $client->secret,
]); ]);
$user->update(['authority_level' => 1]); $user->update(['authority_level' => 1]);
return $client;
}); });
return $this->successResponse([
return $this->successResponse(); 'client_id' => $passportClient->id,
'client_secret' => $passportClient->secret,
]);
} }
public function show(UserGateway $gateway): JsonResponse public function show(UserGateway $gateway): JsonResponse
{ {
return $this->successResponse($gateway); return $this->successResponse($gateway);

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('user_gateways', function (Blueprint $table) {
$table->string('client_id')->nullable();
$table->string('client_secret')->nullable();
$table->integer('status')->default(0);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('user_gateways', function (Blueprint $table) {
$table->dropColumn(['client_id', 'client_secret','status']);
});
}
};

View File

@@ -77,7 +77,7 @@ Route::prefix('expert')
Route::prefix('profile') Route::prefix('profile')
->name('profile.') ->name('profile.')
->middleware('auth') ->middleware('auth:expert')
->controller(ProfileController::class) ->controller(ProfileController::class)
->group(function () { ->group(function () {
Route::get('info', 'info')->name('info'); Route::get('info', 'info')->name('info');