v4.1.9: Начальная производственная версия
- Полный backend на Hono + TypeScript - SQLite база данных с 38 записями - 3 пользователя: admin, aknaproff, kasutaja - Модальное окно reportModal (4 шага) - Docker конфигурация для Synology ARM - Все миграции (0001-0017) - Frontend: vanilla HTML/JS (original.html)
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ManageProfileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the form for editing the profile.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function getProfile()
|
||||
{
|
||||
$user_id = request()->user()->id;
|
||||
|
||||
$user = User::find($user_id);
|
||||
|
||||
return view('user.profile.edit')
|
||||
->with(compact('user'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified profile.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function postProfile(Request $request, $id)
|
||||
{
|
||||
$validate = validator($request->all(), [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email|unique:users,email,'.$id,
|
||||
]);
|
||||
|
||||
if ($validate->fails()) {
|
||||
return $this->respondWithError($validate->errors()->first());
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
//check for demo
|
||||
if ($this->isDemo()) {
|
||||
return $this->respondDemo();
|
||||
}
|
||||
|
||||
if (request()->ajax()) {
|
||||
$input = request()->only('name', 'email');
|
||||
$password = request('password');
|
||||
|
||||
if (! empty($password)) {
|
||||
$input['password'] = bcrypt($password);
|
||||
}
|
||||
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
$user->update($input);
|
||||
|
||||
$dashboard_url['redirect'] = action([\App\Http\Controllers\HomeController::class, 'index']);
|
||||
$output = $this->respondSuccess(__('messages.success'), $dashboard_url);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$output = $this->respondWentWrong($e);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user