feat: allow users to delete/create own profile
This commit is contained in:
@@ -21,6 +21,9 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Exceptions\ProfileAlreadyExistsException;
|
||||
use App\Exceptions\ProfileCreationFailedException;
|
||||
use App\Exceptions\ProfileNotFoundException;
|
||||
use App\Facades\IP;
|
||||
use App\Http\Requests\ProfileSave;
|
||||
use App\Services\ProfileService;
|
||||
@@ -123,4 +126,44 @@ class ProfileController extends Controller
|
||||
->back()
|
||||
->with('success', __('Profile updated.'));
|
||||
}
|
||||
|
||||
|
||||
public function createProfile(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$this->profileService->createProfile($request->user());
|
||||
} catch (\Exception $e) {
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('error', $e->getMessage());
|
||||
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('success', __('Your profile has been created.'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function deleteProfile(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$this->profileService->deleteProfile($request->user());
|
||||
} catch (ProfileNotFoundException $e) {
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('error', $e->getMessage());
|
||||
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('success', __('Profile deleted successfully.'));
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user