App\Traits\UserAvatar::setAvatar PHP Method

setAvatar() public method

public setAvatar ( $file )
    public function setAvatar($file)
    {
        if ($file === null) {
            $this->avatarStorage()->delete($this->user_id);
        } else {
            $filePath = $file->getRealPath();
            (new ImageProcessor($filePath, [256, 256], 100000))->process();
            $this->avatarStorage()->put($this->user_id, file_get_contents($filePath), 'public');
            $entry = $this->user_id . '_' . time();
        }
        if (present(config('osu.avatar.cache_purge_prefix'))) {
            file_get_contents(config('osu.avatar.cache_purge_prefix') . $this->user_id . '?' . time());
        }
        return $this->update(['user_avatar' => $entry ?? null]);
    }