Merge pull request #8 from Ritikeshyadav/RitikeshFreeu
fixed update user profile api and helper function
@@ -43,37 +43,9 @@ class ProfileController extends Controller
|
||||
if ($validationMessage) {
|
||||
return response()->json(['status' => 400, 'message' => $validationMessage]);
|
||||
}
|
||||
// dd($request->all());
|
||||
|
||||
$user = User::where('id', $request->id)->first();
|
||||
|
||||
// dd($user,$user['profile_image'] ,$user->profile_image,$request->profile_image);
|
||||
|
||||
|
||||
// return $user->getRawOriginal('profile_image');
|
||||
|
||||
// if ($request->has('profile_image')) {
|
||||
// if (\File::exists(public_path('/uploads/profile/img/' . $user->getRawOriginal('profile_image') . ''))) {
|
||||
// \File::delete(public_path('/uploads/profile/img/' . $user->getRawOriginal('profile_image') . ''));
|
||||
// }
|
||||
// $profileImageName = time() . '.' . $request->profile_image->extension();
|
||||
// $request->profile_image->move(public_path('/uploads/profile/img'), $profileImageName);
|
||||
// $updateCompanyLogo = User::where('id', $request->id)->update([
|
||||
// 'profile_image' => $profileImageName,
|
||||
// ]);
|
||||
// }
|
||||
// dd($request->profile_image);
|
||||
|
||||
// dd($this->imageUpload($request->profile_image,$request->id));
|
||||
$image = $request->has('profile_image') ? $this->imageUpload($request->profile_image, $request->id) : $user->getRawOriginal('profile_image');
|
||||
// if($request->has('profile_image'))
|
||||
// {
|
||||
// $image = $this->imageUpload($request->profile_image,$request->id);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $image = $user->profile_image;
|
||||
// }
|
||||
// dd($image);
|
||||
|
||||
$addUser = User::where('id', $request->id)->update([
|
||||
'name' => $request->name,
|
||||
@@ -110,9 +82,9 @@ class ProfileController extends Controller
|
||||
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required',
|
||||
'email' => 'required',
|
||||
'contact_number' => 'required|min:10|max:10|unique:users,contact_number,' . $request->user()->id . '',
|
||||
// 'profile_image' => 'required',
|
||||
// 'email' => 'required',
|
||||
// 'contact_number' => 'required|min:10|max:10|unique:users,contact_number,' . $request->user()->id . '',
|
||||
'profile_image' => 'image|mimes:jpeg,jpg,png|max:2000',
|
||||
'address' => 'required'
|
||||
], [
|
||||
'required' => 'The :attribute field must be required',
|
||||
@@ -127,22 +99,26 @@ class ProfileController extends Controller
|
||||
}
|
||||
|
||||
$user = User::find($request->user()->id);
|
||||
if ($request->has('profile_image')) {
|
||||
if (\File::exists(public_path('/uploads/profile/img/' . $user->profile_image . ''))) {
|
||||
\File::delete(public_path('/uploads/profile/img/' . $user->profile_image . ''));
|
||||
}
|
||||
$profileImageName = time() . '.' . $request->profile_image->extension();
|
||||
$request->profile_image->move(public_path('/uploads/profile/img'), $profileImageName);
|
||||
$updateCompanyLogo = User::where('id', $request->user()->id)->update([
|
||||
'profile_image' => $profileImageName,
|
||||
]);
|
||||
}
|
||||
|
||||
// if ($request->has('profile_image')) {
|
||||
// if (\File::exists(public_path('/uploads/profile/img/' . $user->profile_image . ''))) {
|
||||
// \File::delete(public_path('/uploads/profile/img/' . $user->profile_image . ''));
|
||||
// }
|
||||
// // dd('inside');
|
||||
// $profileImageName = time() . '.' . $request->profile_image->extension();
|
||||
// $request->profile_image->move(public_path('/uploads/profile/img'), $profileImageName);
|
||||
// $updateCompanyLogo = User::where('id', $request->user()->id)->update([
|
||||
// 'profile_image' => $profileImageName,
|
||||
// ]);
|
||||
// }
|
||||
// dd($user);
|
||||
$image = $request->has('profile_image') ? $this->imageUpload($request->profile_image, $request->user()->id) : $user->getRawOriginal('profile_image');
|
||||
// dd($image);
|
||||
$addUser = User::where('id', $request->user()->id)->update([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'contact_number' => $request->contact_number,
|
||||
'address' => $request->address
|
||||
// 'email' => $request->email,
|
||||
// 'contact_number' => $request->contact_number,
|
||||
'address' => $request->address,
|
||||
'profile_image' => $image,
|
||||
]);
|
||||
if ($addUser) {
|
||||
return response()->json(['status' => 200, 'message' => 'Details Updated Successfully!']);
|
||||
|
||||
@@ -41,10 +41,14 @@ function imagePath($path = null)
|
||||
{
|
||||
$finalPath = "https://jerichoalternatives.in/";
|
||||
}
|
||||
if(env('APP_ENV') == 'local')
|
||||
if(env('APP_ENV') == 'staging')
|
||||
{
|
||||
$finalPath = "https://staging.jerichoalternatives.in/";
|
||||
}
|
||||
if(env('APP_ENV') == 'local')
|
||||
{
|
||||
$finalPath = "http://localhost/jericho_28_march/";
|
||||
}
|
||||
return $finalPath.$path;
|
||||
}
|
||||
|
||||
|
||||
BIN
public/uploads/profile/img/1711693296.jpg
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
public/uploads/profile/img/1711694482.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/uploads/profile/img/1711694856.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/uploads/profile/img/1711695168.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/uploads/profile/img/1711695305.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/uploads/profile/img/1711695308.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/uploads/profile/img/1711695309.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
@@ -160,7 +160,7 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
|
||||
Route::get('get-user', [AuthController::class, 'getUser']);
|
||||
Route::post("update-profile", [ProfileController::class, 'updateAPI']);
|
||||
Route::post('logout', [AuthController::class, 'userLogout']);
|
||||
Route::post("update-profile", [ProfileController::class, 'updateAPI']);
|
||||
// Route::post("update-profile", [ProfileController::class, 'updateAPI']);
|
||||
Route::post("personal-information-kyc", [AccountsController::class, 'personalInformationKYC']);
|
||||
Route::post("location-information-kyc", [AccountsController::class, 'locationInformationKYC']);
|
||||
Route::post("pan-aadhar-kyc", [AccountsController::class, 'panAadharInformationKYC']);
|
||||
|
||||