Merge branch 'feature/EditProfileBugFix' into 'develop'

return the full path of avatar

See merge request witelgroup/rms_v2!16
This commit is contained in:
Hamidreza Ranjbarpour
2024-09-16 06:33:59 +00:00
2 changed files with 9 additions and 2 deletions

View File

@@ -29,7 +29,7 @@ class ProfileController extends Controller
'major' => $user->major,
'degree' => $user->degree,
'mobile' => $user->mobile,
'avatar' => $user->avatar,
'avatar' => $user->avatarUrl()
]);
}

View File

@@ -7,6 +7,7 @@ use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Spatie\Permission\Traits\HasRoles;
use Spatie\Permission\Traits\HasPermissions;
use Illuminate\Database\Eloquent\Factories\HasFactory;
@@ -24,7 +25,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'username', 'first_name', 'last_name', 'position', 'mobile', 'province_id', 'city_id', 'confirmed', 'enabled', 'avatar', 'city_fa', 'province_fa', 'degree'
'name', 'email', 'major', 'password', 'username', 'first_name', 'last_name', 'position', 'mobile', 'province_id', 'city_id', 'confirmed', 'enabled', 'avatar', 'city_fa', 'province_fa', 'degree'
];
/**
@@ -228,4 +229,10 @@ class User extends Authenticatable
{
return $this->hasMany('App\Models\RoadConstructionRural');
}
public function avatarUrl(): ?string
{
$avatar = $this->attributes['avatar'];
return $avatar == null ? null : Storage::disk('public')->url($avatar);
}
}