在Laravel Eloquent模型中,可以通过定义访问器来处理profile_image属性,若属性为空则返回/user.png。示例代码为:public function getProfileImageAttribute($value) { return $value ? asset('/storage' . $value) : url('/user.png'); } 这样在Blade模板中可直接使用auth()->user()->profile_image。
完成下面两步后,将自动完成登录并继续当前操作。