opnform/app/Http/Controllers/Auth/UserController.php

34 lines
757 B
PHP
Raw Normal View History

2022-09-20 19:59:52 +00:00
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Http\Resources\UserResource;
2022-09-20 19:59:52 +00:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class UserController extends Controller
{
/**
* Get authenticated user.
*
*/
public function current(Request $request)
{
return new UserResource($request->user());
2022-09-20 19:59:52 +00:00
}
public function deleteAccount() {
$this->middleware('auth');
if (Auth::user()->admin) {
return $this->error([
'message' => 'Cannot delete an admin. Stay with us 🙏'
]);
}
Auth::user()->delete();
return $this->success([
'message' => 'User deleted.'
]);
}
}