ProfileController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Models\User;
  5. use Hash;
  6. class ProfileController extends Controller
  7. {
  8. /**
  9. * Display a listing of the resource.
  10. *
  11. * @return \Illuminate\Http\Response
  12. */
  13. public function index()
  14. {
  15. return view('backend.admin_profile.index');
  16. }
  17. /**
  18. * Show the form for creating a new resource.
  19. *
  20. * @return \Illuminate\Http\Response
  21. */
  22. public function create()
  23. {
  24. //
  25. }
  26. /**
  27. * Store a newly created resource in storage.
  28. *
  29. * @param \Illuminate\Http\Request $request
  30. * @return \Illuminate\Http\Response
  31. */
  32. public function store(Request $request)
  33. {
  34. //
  35. }
  36. /**
  37. * Display the specified resource.
  38. *
  39. * @param int $id
  40. * @return \Illuminate\Http\Response
  41. */
  42. public function show($id)
  43. {
  44. //
  45. }
  46. /**
  47. * Show the form for editing the specified resource.
  48. *
  49. * @param int $id
  50. * @return \Illuminate\Http\Response
  51. */
  52. public function edit($id)
  53. {
  54. //
  55. }
  56. /**
  57. * Update the specified resource in storage.
  58. *
  59. * @param \Illuminate\Http\Request $request
  60. * @param int $id
  61. * @return \Illuminate\Http\Response
  62. */
  63. public function update(Request $request, $id)
  64. {
  65. if(env('DEMO_MODE') == 'On'){
  66. flash(translate('Sorry! the action is not permitted in demo '))->error();
  67. return back();
  68. }
  69. $user = User::findOrFail($id);
  70. $user->name = $request->name;
  71. $user->email = $request->email;
  72. if($request->new_password != null && ($request->new_password == $request->confirm_password)){
  73. $user->password = Hash::make($request->new_password);
  74. }
  75. $user->avatar_original = $request->avatar;
  76. if($user->save()){
  77. flash(translate('Your Profile has been updated successfully!'))->success();
  78. return back();
  79. }
  80. flash(translate('Sorry! Something went wrong.'))->error();
  81. return back();
  82. }
  83. /**
  84. * Remove the specified resource from storage.
  85. *
  86. * @param int $id
  87. * @return \Illuminate\Http\Response
  88. */
  89. public function destroy($id)
  90. {
  91. //
  92. }
  93. }