🐛 修复 BUG

This commit is contained in:
Wisp X 2022-02-11 08:42:28 +08:00
parent 5d64068456
commit 6d8031b0a2
9 changed files with 390 additions and 444 deletions

View File

@ -5,10 +5,13 @@ namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\UserRequest; use App\Http\Requests\Admin\UserRequest;
use App\Models\User; use App\Models\User;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Illuminate\View\View; use Illuminate\View\View;
class UserController extends Controller class UserController extends Controller
@ -36,6 +39,14 @@ class UserController extends Controller
/** @var User $user */ /** @var User $user */
$user = User::query()->findOrFail($request->route('id')); $user = User::query()->findOrFail($request->route('id'));
$user->fill($request->validated()); $user->fill($request->validated());
if ($password = $request->validated('password')) {
$user->forceFill([
'password' => Hash::make($password),
'remember_token' => Str::random(60),
]);
event(new PasswordReset($user));
}
if (!$user->save()) { if (!$user->save()) {
return $this->error('保存失败'); return $this->error('保存失败');
} }

View File

@ -53,7 +53,7 @@ class UserController extends Controller
$user->forceFill([ $user->forceFill([
'password' => Hash::make($password), 'password' => Hash::make($password),
'remember_token' => Str::random(60), 'remember_token' => Str::random(60),
])->save(); ]);
event(new PasswordReset($user)); event(new PasswordReset($user));
} }

View File

@ -12,8 +12,6 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Laravel\Sanctum\HasApiTokens; use Laravel\Sanctum\HasApiTokens;
/** /**
@ -91,15 +89,6 @@ class User extends Authenticatable implements MustVerifyEmail
UserConfigKey::IsAutoClearPreview => false, UserConfigKey::IsAutoClearPreview => false,
])->merge($user->configs ?: []); ])->merge($user->configs ?: []);
}); });
static::saving(function (self $user) {
if ($user->password) {
$user->password = Hash::make($user->password);
$user->remember_token = Str::random(60);
} else {
unset($user->password);
}
});
} }
public function group(): BelongsTo public function group(): BelongsTo

View File

@ -13,7 +13,6 @@ class AppLayout extends Component
*/ */
public function render() public function render()
{ {
$is_full = request()->routeIs('images', 'gallery'); return view('layouts.app');
return view('layouts.app', compact('is_full'));
} }
} }

68
composer.lock generated
View File

@ -114,16 +114,16 @@
}, },
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",
"version": "3.209.21", "version": "3.209.22",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/aws/aws-sdk-php.git", "url": "https://github.com/aws/aws-sdk-php.git",
"reference": "3f5b867920f422d605c38aad95f5c334183b39bb" "reference": "2f8a8c885daf45fe9f919312a66a68115d6733b5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3f5b867920f422d605c38aad95f5c334183b39bb", "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/2f8a8c885daf45fe9f919312a66a68115d6733b5",
"reference": "3f5b867920f422d605c38aad95f5c334183b39bb", "reference": "2f8a8c885daf45fe9f919312a66a68115d6733b5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -199,9 +199,9 @@
"support": { "support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues", "issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.209.21" "source": "https://github.com/aws/aws-sdk-php/tree/3.209.22"
}, },
"time": "2022-02-09T19:17:07+00:00" "time": "2022-02-10T19:14:07+00:00"
}, },
{ {
"name": "brick/math", "name": "brick/math",
@ -1243,16 +1243,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v9.0.1", "version": "v9.0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "afeb58d019b203ecb1a1c4063a66a029ea6bea63" "reference": "4c7cd8c4e95d161c0c6ada6efa0a5af4d0d487c9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/afeb58d019b203ecb1a1c4063a66a029ea6bea63", "url": "https://api.github.com/repos/laravel/framework/zipball/4c7cd8c4e95d161c0c6ada6efa0a5af4d0d487c9",
"reference": "afeb58d019b203ecb1a1c4063a66a029ea6bea63", "reference": "4c7cd8c4e95d161c0c6ada6efa0a5af4d0d487c9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1418,7 +1418,7 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2022-02-09T15:00:05+00:00" "time": "2022-02-10T15:07:46+00:00"
}, },
{ {
"name": "laravel/sanctum", "name": "laravel/sanctum",
@ -1799,16 +1799,16 @@
}, },
{ {
"name": "league/flysystem", "name": "league/flysystem",
"version": "3.0.3", "version": "3.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/flysystem.git", "url": "https://github.com/thephpleague/flysystem.git",
"reference": "9f8b4260031bfef5497477da53dd57b2aaff0e06" "reference": "aef771741948595bfbed8e0342dd340695a368ff"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/9f8b4260031bfef5497477da53dd57b2aaff0e06", "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/aef771741948595bfbed8e0342dd340695a368ff",
"reference": "9f8b4260031bfef5497477da53dd57b2aaff0e06", "reference": "aef771741948595bfbed8e0342dd340695a368ff",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1868,7 +1868,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/thephpleague/flysystem/issues", "issues": "https://github.com/thephpleague/flysystem/issues",
"source": "https://github.com/thephpleague/flysystem/tree/3.0.3" "source": "https://github.com/thephpleague/flysystem/tree/3.0.4"
}, },
"funding": [ "funding": [
{ {
@ -1884,7 +1884,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-01-31T19:41:04+00:00" "time": "2022-02-10T16:14:03+00:00"
}, },
{ {
"name": "league/flysystem-aws-s3-v3", "name": "league/flysystem-aws-s3-v3",
@ -1944,16 +1944,16 @@
}, },
{ {
"name": "league/flysystem-ftp", "name": "league/flysystem-ftp",
"version": "3.0.3", "version": "3.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/flysystem-ftp.git", "url": "https://github.com/thephpleague/flysystem-ftp.git",
"reference": "b905a8882187035f067a9b774ed89ddc9a382a92" "reference": "408b2ba9dedfb9685e8ab9a24d4ca9b4fe636149"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem-ftp/zipball/b905a8882187035f067a9b774ed89ddc9a382a92", "url": "https://api.github.com/repos/thephpleague/flysystem-ftp/zipball/408b2ba9dedfb9685e8ab9a24d4ca9b4fe636149",
"reference": "b905a8882187035f067a9b774ed89ddc9a382a92", "reference": "408b2ba9dedfb9685e8ab9a24d4ca9b4fe636149",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1988,7 +1988,7 @@
"ftpd" "ftpd"
], ],
"support": { "support": {
"source": "https://github.com/thephpleague/flysystem-ftp/tree/3.0.3" "source": "https://github.com/thephpleague/flysystem-ftp/tree/3.0.4"
}, },
"funding": [ "funding": [
{ {
@ -2004,7 +2004,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-01-31T19:10:15+00:00" "time": "2022-02-10T16:09:00+00:00"
}, },
{ {
"name": "league/flysystem-sftp", "name": "league/flysystem-sftp",
@ -8275,16 +8275,16 @@
}, },
{ {
"name": "sebastian/global-state", "name": "sebastian/global-state",
"version": "5.0.3", "version": "5.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git", "url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" "reference": "19c519631c5a511b7ed0ad64a6713fdb3fd25fe4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/19c519631c5a511b7ed0ad64a6713fdb3fd25fe4",
"reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", "reference": "19c519631c5a511b7ed0ad64a6713fdb3fd25fe4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -8327,7 +8327,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues", "issues": "https://github.com/sebastianbergmann/global-state/issues",
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.4"
}, },
"funding": [ "funding": [
{ {
@ -8335,7 +8335,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2021-06-11T13:31:12+00:00" "time": "2022-02-10T07:01:19+00:00"
}, },
{ {
"name": "sebastian/lines-of-code", "name": "sebastian/lines-of-code",
@ -8932,16 +8932,16 @@
}, },
{ {
"name": "spatie/laravel-ignition", "name": "spatie/laravel-ignition",
"version": "1.0.3", "version": "1.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/spatie/laravel-ignition.git", "url": "https://github.com/spatie/laravel-ignition.git",
"reference": "68250225a9f83b086462c2af1b1139dfde48fbd2" "reference": "ca49c7f74022de49910715e8f1ac5ce52123eb3e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/68250225a9f83b086462c2af1b1139dfde48fbd2", "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/ca49c7f74022de49910715e8f1ac5ce52123eb3e",
"reference": "68250225a9f83b086462c2af1b1139dfde48fbd2", "reference": "ca49c7f74022de49910715e8f1ac5ce52123eb3e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9015,7 +9015,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-02-04T15:25:56+00:00" "time": "2022-02-10T08:50:40+00:00"
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,5 @@
<div {{ $attributes->merge(['class' => ($full ?? false) ? 'h-full mx-auto sm:ml-64' : 'h-full mx-auto sm:ml-64 px-6 md:px-10 lg:px-10 xl:px-10 2xl:px-60']) }}> @props(['full' => request()->routeIs('images', 'gallery')])
<div {{ $attributes->merge(['class' => $full ? 'h-full mx-auto sm:ml-64' : 'h-full mx-auto sm:ml-64 px-6 md:px-10 lg:px-10 xl:px-10 2xl:px-60']) }}>
{{ $slot }} {{ $slot }}
</div> </div>

View File

@ -41,7 +41,7 @@
> >
</div> </div>
<x-container full="{{ $is_full }}" class="flex flex-col overflow-y-auto absolute pb-14 top-14 left-0 right-0 bottom-0 transition-all duration-300 min-h-screen h-full"> <x-container class="flex flex-col overflow-y-auto absolute pb-14 top-14 left-0 right-0 bottom-0 transition-all duration-300 min-h-screen h-full">
{{ $slot }} {{ $slot }}
</x-container> </x-container>
</div> </div>

View File

@ -1,11 +1,20 @@
@section('title', '画廊') @section('title', '画廊')
@push('styles')
@endpush
<x-app-layout> <x-app-layout>
1 <div class="max-w-2xl p-4 lg:max-w-7xl">
<div class="grid grid-cols-1 gap-y-10 gap-x-6 sm:grid-cols-2 md:grid-cols-4 xl:grid-cols-6 lg:grid-cols-8 xl:gap-x-8">
@foreach(\App\Models\Image::all() as $image)
<div class="flex flex-col bg-white rounded-md h-56 overflow-hidden">
<div class="flex justify-center items-center grow p-2 bg-auto bg-no-repeat bg-center bg-cover">
<img class="block object-cover" src="{{ $image->thumb_url }}">
</div>
<div class="flex">
11
</div>
</div>
@endforeach
</div>
</div>
@push('scripts') @push('scripts')
<script> <script>