create edit in profile controller foe expert and this dependency
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Requests\Profile\ChangePasswordRequest;
|
||||
use App\Admin\Requests\Profile\EditRequest;
|
||||
use App\Admin\Resources\ExpertResource;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Traits\ApiResponse;
|
||||
@@ -19,6 +20,24 @@ class ProfileController extends Controller
|
||||
return $this->successResponse(new ExpertResource(Auth::guard('expert')->user()));
|
||||
}
|
||||
|
||||
public function edit(EditRequest $request): JsonResponse
|
||||
{
|
||||
$expert = $request->user('expert');
|
||||
|
||||
$expert->update([
|
||||
'username' => $request->username,
|
||||
'first_name' => $request->first_name,
|
||||
'last_name' => $request->last_name,
|
||||
'email' => $expert->email,
|
||||
'national_id' => $request->national_id,
|
||||
'phone_number' => $request->phone_number,
|
||||
'province_id' => $request->province_id,
|
||||
'city_id' => $request->city_id,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function changePassword(ChangePasswordRequest $request): JsonResponse
|
||||
{
|
||||
$expert = Auth::guard('expert')->user();
|
||||
|
||||
36
backend/app/Admin/Requests/Profile/EditRequest.php
Normal file
36
backend/app/Admin/Requests/Profile/EditRequest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Requests\Profile;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class EditRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'username' => 'string|max:255',
|
||||
'first_name' => 'string',
|
||||
'last_name' => 'string',
|
||||
'email' => 'string|email|max:255',
|
||||
'national_id' => 'string',
|
||||
'phone_number' => 'string',
|
||||
'province_id' => 'string',
|
||||
'city_id' => 'string',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use App\Admin\Controllers\AuthController;
|
||||
use App\Admin\Controllers\DocumentationController;
|
||||
use App\Admin\Controllers\ProfileController;
|
||||
|
||||
Route::prefix('auth')
|
||||
->name('auth.')
|
||||
@@ -22,3 +23,13 @@ Route::prefix('documents')
|
||||
Route::post('reject', 'reject')->name('reject');
|
||||
Route::get('files/{user}', 'files')->name('files');
|
||||
});
|
||||
|
||||
Route::prefix('profile')
|
||||
->name('profile.')
|
||||
->middleware('auth')
|
||||
->controller(ProfileController::class)
|
||||
->group(function () {
|
||||
Route::get('info', 'info')->name('info');
|
||||
Route::post('edit', 'edit')->name('edit');
|
||||
Route::post('change_password', 'changePassword')->name('changePassword');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user