-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update inertia to pull in and save profile photo's from provider avatars
- Loading branch information
Joel Butcher
committed
Feb 4, 2021
1 parent
0c8e25b
commit 68db04e
Showing
3 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Http/Controllers/Inertia/UpdateUserProfilePhotoController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace JoelButcher\Socialstream\Http\Controllers\Inertia; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Routing\Controller; | ||
|
||
class UpdateUserProfilePhotoController extends Controller | ||
{ | ||
/** | ||
* Update the users profile picture from the connected account's avatar. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function __invoke(Request $request) | ||
{ | ||
$account = ($user = $request->user())->connectedAccounts | ||
->where('user_id', $user->getAuthIdentifier()) | ||
->where('id', $request->id) | ||
->first(); | ||
|
||
if (is_callable([$user, 'setProfilePhotoFromUrl']) && ! is_null($account->avatar_path)) { | ||
$user->setProfilePhotoFromUrl($account->avatar_path); | ||
} | ||
|
||
return back(303); | ||
} | ||
} |