Compare commits
7 Commits
feature/Fi
...
feature/Fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f133107b9f | ||
| 08b0cd4cca | |||
| 4eec548b83 | |||
| 675d2bdbad | |||
| 69ffe322ce | |||
| a1466d8f57 | |||
| 392fca8635 |
@@ -29,6 +29,16 @@ class DocumentationController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function show(User $user): JsonResponse
|
||||||
|
{
|
||||||
|
$data=User::query()
|
||||||
|
->with([
|
||||||
|
'gateway:id,user_id,domain,tax_id,bank_name,account_holder,logo',
|
||||||
|
'documents:id,documentable_id,documentable_type,title,url',
|
||||||
|
])->find($user);
|
||||||
|
return $this->successResponse($data);
|
||||||
|
}
|
||||||
|
|
||||||
public function files(User $user): JsonResponse
|
public function files(User $user): JsonResponse
|
||||||
{
|
{
|
||||||
return $this->successResponse($user->load('documents'));
|
return $this->successResponse($user->load('documents'));
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ use Database\Factories\UserFactory;
|
|||||||
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
||||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
@@ -22,9 +23,13 @@ class User extends Authenticatable
|
|||||||
use HasFactory, Notifiable, HasApiTokens;
|
use HasFactory, Notifiable, HasApiTokens;
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
public function documents(): MorphToMany
|
public function documents(): MorphMany
|
||||||
{
|
{
|
||||||
return $this->morphToMany(Document::class, 'documentable');
|
return $this->morphMany(Document::class, 'documentable');
|
||||||
|
}
|
||||||
|
public function gateway(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(UserGateway::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateForPassportPasswordGrant(string $password): bool
|
public function validateForPassportPasswordGrant(string $password): bool
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -22,6 +22,7 @@ Route::prefix('documents')
|
|||||||
->controller(DocumentationController::class)
|
->controller(DocumentationController::class)
|
||||||
->group(function () {
|
->group(function () {
|
||||||
Route::get('/', 'index')->name('index');
|
Route::get('/', 'index')->name('index');
|
||||||
|
Route::get('/{user}', 'show')->name('show');
|
||||||
Route::post('confirm/{user}', 'confirm')->name('confirm');
|
Route::post('confirm/{user}', 'confirm')->name('confirm');
|
||||||
Route::post('reject/{user}', 'reject')->name('reject');
|
Route::post('reject/{user}', 'reject')->name('reject');
|
||||||
Route::get('files/{user}', 'files')->name('files');
|
Route::get('files/{user}', 'files')->name('files');
|
||||||
@@ -77,7 +78,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');
|
||||||
|
|||||||
Reference in New Issue
Block a user