Revert "Revert "merge 1""

This reverts commit 0c463d1f10.
This commit is contained in:
2022-10-24 01:04:22 +01:00
parent 0c463d1f10
commit b89d71b371
166 changed files with 4250 additions and 1833 deletions

View File

@@ -21,7 +21,10 @@
namespace App\Observers;
use App\Exceptions\ProfileAlreadyExistsException;
use App\Exceptions\ProfileCreationFailedException;
use App\Profile;
use App\Services\ProfileService;
use App\User;
use Illuminate\Support\Facades\Log;
@@ -40,15 +43,24 @@ class UserObserver
*/
public function created(User $user)
{
// TODO: Make sure that the profile is created, throw an exception if otherwise, or try to recreate the profile.
Profile::create([
$profileService = new ProfileService();
'profileShortBio' => 'Write a one-liner about you here!',
'profileAboutMe' => 'Tell us a bit about you.',
'socialLinks' => '{}',
'userID' => $user->id,
]);
try
{
$profileService->createProfile($user);
}
catch (ProfileAlreadyExistsException $exception)
{
Log::error('Attempting to create profile that already exists!', [
'trace' => $exception->getTrace()
]);
}
catch (ProfileCreationFailedException $e)
{
Log::error('Failed creating a new profile!', [
'trace' => $e->getTrace()
]);
}
}
/**