Skip to content

Commit

Permalink
Merge pull request #15 from P3D-Legacy/release/0.3.3
Browse files Browse the repository at this point in the history
Release/0.3.3
  • Loading branch information
dsbilling authored Apr 16, 2021
2 parents 87786a7 + 74bdebb commit e517693
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

<a name="0.3.3"></a>
## [0.3.3](https://github.com/P3D-Legacy/skin.pokemon3d.net/compare/0.3.2...0.3.3) (2021-04-16)

### Added

* Add admin functionality for uploaded skins [#14](https://github.com/P3D-Legacy/skin.pokemon3d.net/issues/14)

<a name="0.3.2"></a>
## [0.3.2](https://github.com/P3D-Legacy/skin.pokemon3d.net/compare/0.3.1...0.3.2) (2021-04-12)

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function index(Request $request)
$user = $auth['response']['users'][0];
}

$activity = Activity::where('description' , 'deleted')->where('properties', 'LIKE', '%'.$request->session()->get('gjid').'.png%')->get();
$activity = Activity::where('description' , 'deleted')->where('properties', 'LIKE', '%'.$request->session()->get('gjid').'.png%')->orWhere('properties', 'LIKE', '%gjid":'.$request->session()->get('gjid').',"reason"%')->get();

return view('home')->with($user)->with('activity', $activity);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/PlayerSkinController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function destroyAsAdmin(Request $request, $gjid)
if(!Storage::disk('player')->exists($filename)) {
return redirect()->route('player-skins')->with('error', 'Skin was not found!');
}
activity()->causedBy(GJUser::where('gjid', session()->get('gjid'))->first())->withProperties(['filename' => $filename, 'reason' => $request->reason])->log('deleted');
activity()->causedBy(GJUser::where('gjid', session()->get('gjid'))->first())->withProperties(['filename' => $filename, 'gjid' => $gjid, 'reason' => $request->reason])->log('deleted');
Storage::disk('player')->delete($filename);
return redirect()->route('player-skins')->with('success', 'Skin was successfully deleted!');
}
Expand Down
103 changes: 103 additions & 0 deletions app/Http/Controllers/UploadedSkinController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php

namespace App\Http\Controllers;

use App\Models\Skin;
use App\Models\GJUser;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class UploadedSkinController extends Controller
{
public function __construct()
{
$this->middleware(['gj.auth', 'gj.admin']);
}

/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$skins = Skin::all();
return view('uploaded-skin.index')->with('skins', $skins);
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy(Request $request, $uuid)
{
$request->validate([
'reason' => ['required', 'string'],
]);
$skin = Skin::where('uuid', $uuid)->first();
if(!Storage::disk('skin')->exists($skin->path())) {
return redirect()->route('uploaded-skins')->with('error', 'Skin was not found!');
}
activity()->causedBy(GJUser::where('gjid', session()->get('gjid'))->first())->withProperties(['filename' => $skin->path(), 'gjid' => $skin->user->gjid, 'reason' => $request->reason])->log('deleted');
$skin->delete();
Storage::disk('skin')->delete($skin->path());
return redirect()->route('uploaded-skins')->with('success', 'Skin was successfully deleted!');
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"webpatser/laravel-uuid": "^3.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.5",
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
Expand Down
217 changes: 216 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion resources/views/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="row">
<div class="col-lg-3">
<div class="card mb-3">
<div class="card-header">Your Current Skin<a class="btn btn-sm btn-outline-danger float-end" href="{{ route('player-skin-destroy') }}" role="button"><i class="fas fa-user-slash"></i> Delete</a></div>
<div class="card-header">Your Current Skin @if(File::exists(public_path('player/'.$id.'.png')))<a class="btn btn-sm btn-outline-danger float-end" href="{{ route('player-skin-destroy') }}" role="button"><i class="fas fa-user-slash"></i> Delete</a>@endif</div>
<div class="card-body">
@if(File::exists(public_path('player/'.$id.'.png')))
<img src="{{ asset('player/'.$id.'.png') }}?r={{ \Carbon\Carbon::now()->timestamp }}">
Expand Down
Loading

0 comments on commit e517693

Please sign in to comment.