<?php

namespace App\Http\Controllers\Backend;

use App\Models\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Session;

class PasswordController extends Controller
{
    public function index()
    {
        return view('admin.password');
    }

    public function update(Request $request)
    {
        $this->validate($request, [
            'qpwd1' => 'required|max:255',
        ]);

        $user = User::find($request->user()->id);
        $user->password = bcrypt($request->qpwd1);
        $user->save();

        Session::flash('msg', 'Update Success!');

        return redirect()->back();
    }
}
