<?php

namespace App\Http\Controllers\accounts;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use App\Models\User;
use App\Notifications\UserNotification;
use Illuminate\Support\Facades\Notification;

class AccountController extends Controller
{
  public function index()
  {
    return view('content.accounts.profil');
  }

  public function changeStatus(Request $request, $userId)
  {
    $user = User::find($userId);
    $user["active"] = !$user["active"];
    $user->fill($user->toArray())->save();

    Notification::send($user, new UserNotification("Status Dirubah", "Admin telah merubah status akunmu!", "/dashboard"));
    return redirect()->route("student")->with("success", "Data Berhasil Diperbarui!");
  }

  public function disable()
  {
    return view('content.accounts.disable');
  }
}
