mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-01-09 04:27:47 +08:00
refactor SkinlibController
This commit is contained in:
parent
d10bcae197
commit
5b738ffe6f
@ -77,21 +77,16 @@ class SkinlibController extends Controller
|
||||
->paginate(20);
|
||||
}
|
||||
|
||||
public function show(Filter $filter, $tid)
|
||||
public function show(Filter $filter, Texture $texture)
|
||||
{
|
||||
$texture = Texture::find($tid);
|
||||
/** @var User */
|
||||
$user = Auth::user();
|
||||
/** @var FilesystemAdapter */
|
||||
$disk = Storage::disk('textures');
|
||||
|
||||
if (!$texture || $texture && $disk->missing($texture->hash)) {
|
||||
if ($disk->missing($texture->hash)) {
|
||||
if (option('auto_del_invalid_texture')) {
|
||||
if ($texture) {
|
||||
$texture->delete();
|
||||
}
|
||||
|
||||
abort(404, trans('skinlib.show.deleted'));
|
||||
$texture->delete();
|
||||
}
|
||||
abort(404, trans('skinlib.show.deleted'));
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ Route::prefix('texture')->name('texture.')->group(function () {
|
||||
Route::prefix('skinlib')->name('skinlib.')->group(function () {
|
||||
Route::view('', 'skinlib.index')->name('home');
|
||||
Route::get('info/{texture}', 'SkinlibController@info')->name('info');
|
||||
Route::get('show/{tid}', 'SkinlibController@show')->name('show');
|
||||
Route::get('show/{texture}', 'SkinlibController@show')->name('show');
|
||||
Route::get('list', 'SkinlibController@library')->name('list');
|
||||
|
||||
Route::middleware(['authorize', 'verified'])->group(function () {
|
||||
|
@ -136,10 +136,6 @@ class SkinlibControllerTest extends TestCase
|
||||
Storage::fake('textures');
|
||||
$filter = Fakes\Filter::fake();
|
||||
|
||||
// Cannot find texture
|
||||
$this->get('/skinlib/show/1')
|
||||
->assertSee(trans('skinlib.show.deleted'));
|
||||
|
||||
// Invalid texture
|
||||
option(['auto_del_invalid_texture' => false]);
|
||||
$texture = factory(Texture::class)->create();
|
||||
|
Loading…
Reference in New Issue
Block a user