前提・実現したいこと
laravel8 jetstreamを利用しています。
jetstreamのprofileを更新するときの、HasProfilePhoto.phpの中の79行目について、構文を教えていただきたいです。
return isset($_ENV['VAPOR_ARTIFACT_NAME']) ? 's3' : 'public';
という文の意味について教えていただきたいです。
該当のソースコード
php
1<?php 2 3namespace Laravel\Jetstream; 4 5use Illuminate\Http\UploadedFile; 6use Illuminate\Support\Facades\Storage; 7use Laravel\Jetstream\Features; 8 9trait HasProfilePhoto 10{ 11 /** 12 * Update the user's profile photo. 13 * 14 * @param \Illuminate\Http\UploadedFile $photo 15 * @return void 16 */ 17 public function updateProfilePhoto(UploadedFile $photo) 18 { 19 tap($this->profile_photo_path, function ($previous) use ($photo) { 20 $this->forceFill([ 21 'profile_photo_path' => $photo->storePublicly( 22 'profile-photos', ['disk' => $this->profilePhotoDisk()] 23 ), 24 ])->save(); 25 26 if ($previous) { 27 Storage::disk($this->profilePhotoDisk())->delete($previous); 28 } 29 }); 30 } 31 32 /** 33 * Delete the user's profile photo. 34 * 35 * @return void 36 */ 37 public function deleteProfilePhoto() 38 { 39 if (! Features::managesProfilePhotos()) { 40 return; 41 } 42 43 Storage::disk($this->profilePhotoDisk())->delete($this->profile_photo_path); 44 45 $this->forceFill([ 46 'profile_photo_path' => null, 47 ])->save(); 48 } 49 50 /** 51 * Get the URL to the user's profile photo. 52 * 53 * @return string 54 */ 55 public function getProfilePhotoUrlAttribute() 56 { 57 return $this->profile_photo_path 58 ? Storage::disk($this->profilePhotoDisk())->url($this->profile_photo_path) 59 : $this->defaultProfilePhotoUrl(); 60 } 61 62 /** 63 * Get the default profile photo URL if no profile photo has been uploaded. 64 * 65 * @return string 66 */ 67 protected function defaultProfilePhotoUrl() 68 { 69 return 'https://ui-avatars.com/api/?name='.urlencode($this->name).'&color=7F9CF5&background=EBF4FF'; 70 } 71 72 /** 73 * Get the disk that profile photos should be stored on. 74 * 75 * @return string 76 */ 77 protected function profilePhotoDisk() 78 { 79 return isset($_ENV['VAPOR_ARTIFACT_NAME']) ? 's3' : config('jetstream.profile_photo_disk', 'public'); 80 } 81}
回答2件
あなたの回答
tips
プレビュー