Compare commits
1 Commits
08b0cd4cca
...
feature/Fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f133107b9f |
@@ -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
|
||||
{
|
||||
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\Hidden;
|
||||
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\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
@@ -22,9 +23,13 @@ class User extends Authenticatable
|
||||
use HasFactory, Notifiable, HasApiTokens;
|
||||
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
|
||||
|
||||
@@ -22,6 +22,7 @@ Route::prefix('documents')
|
||||
->controller(DocumentationController::class)
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index');
|
||||
Route::get('/{user}', 'show')->name('show');
|
||||
Route::post('confirm/{user}', 'confirm')->name('confirm');
|
||||
Route::post('reject/{user}', 'reject')->name('reject');
|
||||
Route::get('files/{user}', 'files')->name('files');
|
||||
|
||||
Reference in New Issue
Block a user