Upload beautify
This commit is contained in:
@@ -4,11 +4,10 @@ namespace App\Http\Controllers\Legacy;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use App\Models\User;
|
||||
use App\Services\AvatarService;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class UserController extends Controller
|
||||
@@ -72,12 +71,12 @@ class UserController extends Controller
|
||||
|
||||
// Files: avatar/photo/emoticon
|
||||
if ($request->hasFile('avatar')) {
|
||||
$f = $request->file('avatar');
|
||||
$name = $user->id . '.' . $f->getClientOriginalExtension();
|
||||
$f->move(public_path('avatar'), $name);
|
||||
// store filename in profile avatar (legacy field) — modern avatar pipeline will later migrate
|
||||
$profileUpdates['avatar'] = $name;
|
||||
$user->icon = $name;
|
||||
try {
|
||||
$hash = app(AvatarService::class)->storeFromUploadedFile((int) $user->id, $request->file('avatar'));
|
||||
$user->icon = $hash;
|
||||
} catch (\Throwable $e) {
|
||||
$request->session()->flash('error', 'Avatar upload failed.');
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->hasFile('personal_picture')) {
|
||||
@@ -141,7 +140,7 @@ class UserController extends Controller
|
||||
if (isset($profile->birthdate)) $user->birth = $profile->birthdate;
|
||||
if (isset($profile->gender)) $user->gender = $profile->gender;
|
||||
if (isset($profile->country_code)) $user->country_code = $profile->country_code;
|
||||
if (isset($profile->avatar)) $user->icon = $profile->avatar;
|
||||
if (isset($profile->avatar_hash)) $user->icon = $profile->avatar_hash;
|
||||
if (isset($profile->cover_image)) $user->picture = $profile->cover_image;
|
||||
if (isset($profile->signature)) $user->signature = $profile->signature;
|
||||
if (isset($profile->description)) $user->description = $profile->description;
|
||||
|
||||
Reference in New Issue
Block a user