From 77e0422334373fe1e6ce7e65395b236081fe45ea Mon Sep 17 00:00:00 2001 From: Joel Butcher Date: Mon, 16 Dec 2024 10:25:34 +0000 Subject: [PATCH] fix: for actions --- composer.json | 1 - src/HasProfilePhoto.php | 89 -------------------- stubs/jetstream/app/Models/User.php | 2 +- stubs/jetstream/app/Models/UserWithTeams.php | 2 +- tests/OrchestraTestCase.php | 1 + 5 files changed, 3 insertions(+), 92 deletions(-) delete mode 100644 src/HasProfilePhoto.php diff --git a/composer.json b/composer.json index eaad7bf6..de021687 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,6 @@ "paragonie/constant_time_encoding": "^2.7" }, "require-dev": { - "laravel/breeze": "^2.0", "laravel/jetstream": "^5.0", "laravel/sanctum": "^4.0", "livewire/livewire": "^3.3.5", diff --git a/src/HasProfilePhoto.php b/src/HasProfilePhoto.php deleted file mode 100644 index 8fcc88d3..00000000 --- a/src/HasProfilePhoto.php +++ /dev/null @@ -1,89 +0,0 @@ -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. - */ - public function profilePhotoUrl(): Attribute - { - return Attribute::get(function () { - 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'); - } -} diff --git a/stubs/jetstream/app/Models/User.php b/stubs/jetstream/app/Models/User.php index ef4c8825..2b475cce 100644 --- a/stubs/jetstream/app/Models/User.php +++ b/stubs/jetstream/app/Models/User.php @@ -71,7 +71,7 @@ protected function casts(): array /** * Get the URL to the user's profile photo. */ - public function profilePhotoUrl(): Attribute + protected function profilePhotoUrl(): Attribute { return filter_var($this->profile_photo_path, FILTER_VALIDATE_URL) ? Attribute::get(fn () => $this->profile_photo_path) diff --git a/stubs/jetstream/app/Models/UserWithTeams.php b/stubs/jetstream/app/Models/UserWithTeams.php index 27be9534..760bf8c5 100644 --- a/stubs/jetstream/app/Models/UserWithTeams.php +++ b/stubs/jetstream/app/Models/UserWithTeams.php @@ -70,7 +70,7 @@ class User extends Authenticatable /** * Get the URL to the user's profile photo. */ - public function profilePhotoUrl(): Attribute + protected function profilePhotoUrl(): Attribute { return filter_var($this->profile_photo_path, FILTER_VALIDATE_URL) ? Attribute::get(fn () => $this->profile_photo_path) diff --git a/tests/OrchestraTestCase.php b/tests/OrchestraTestCase.php index 425963f5..0904a571 100644 --- a/tests/OrchestraTestCase.php +++ b/tests/OrchestraTestCase.php @@ -16,6 +16,7 @@ protected function defineEnvironment($app): void { $app['config']->set('app.debug', true); $app['config']->set('database.default', 'testing'); + $app['config']->set('cache.default', 'file'); $app['config']->set('services.github', [ 'client_id' => 'github-client-id',