pixelfed/app/Observer/UserObserver.php
Daniel Supernault 9dd58c5abd Add profile model, migration and controller
Also added User model observer to create a profile when a new user is
created.
2018-04-15 18:52:22 -06:00

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();
}
}
}