Skip to content

Commit

Permalink
注册用户默认头像
Browse files Browse the repository at this point in the history
  • Loading branch information
summerblue committed Mar 7, 2022
1 parent 82b62f5 commit f3e4846
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions app/Observers/UserObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@

use App\Models\User;

// creating, created, updating, updated, saving,
// saved, deleting, deleted, restoring, restored

class UserObserver
{
public function creating(User $user)
{
//
}

public function updating(User $user)
public function saving(User $user)
{
//
// 这样写扩展性更高,只有空的时候才指定默认头像
if (empty($user->avatar)) {
$user->avatar = 'https://cdn.learnku.com/uploads/images/201710/30/1/TrJS40Ey5k.png';
}
}
}
}

0 comments on commit f3e4846

Please sign in to comment.