mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
9dd58c5abd
Also added User model observer to create a profile when a new user is created.
25 lines
No EOL
467 B
PHP
25 lines
No EOL
467 B
PHP
<?php
|
|
|
|
namespace App\Observers;
|
|
|
|
use App\{Profile, User};
|
|
|
|
class UserObserver
|
|
{
|
|
/**
|
|
* Listen to the User created event.
|
|
*
|
|
* @param \App\User $user
|
|
* @return void
|
|
*/
|
|
public function saved(User $user)
|
|
{
|
|
if($user->has('profile')->count() == 0) {
|
|
$profile = new Profile;
|
|
$profile->user_id = $user->id;
|
|
$profile->username = $user->username;
|
|
$profile->save();
|
|
}
|
|
}
|
|
|
|
} |