27 lines
654 B
PHP
27 lines
654 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Web;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\User;
|
|
use App\Support\UsernamePolicy;
|
|
|
|
class GalleryController extends Controller
|
|
{
|
|
public function show(Request $request, $userId, $username = null)
|
|
{
|
|
$user = User::find((int) $userId);
|
|
if (! $user) {
|
|
abort(404);
|
|
}
|
|
|
|
$usernameSlug = UsernamePolicy::normalize((string) ($user->username ?? $user->name ?? ''));
|
|
if ($usernameSlug === '') {
|
|
abort(404);
|
|
}
|
|
|
|
return redirect()->route('profile.gallery', ['username' => $usernameSlug], 301);
|
|
}
|
|
}
|