mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Update BaseApiController
This commit is contained in:
parent
16336bf5bc
commit
2348621510
1 changed files with 22 additions and 1 deletions
|
@ -7,7 +7,7 @@ use App\Http\Controllers\{
|
|||
Controller,
|
||||
AvatarController
|
||||
};
|
||||
use Auth, Cache, URL;
|
||||
use Auth, Cache, Storage, URL;
|
||||
use Carbon\Carbon;
|
||||
use App\{
|
||||
Avatar,
|
||||
|
@ -290,6 +290,27 @@ class BaseApiController extends Controller
|
|||
return response()->json($res);
|
||||
}
|
||||
|
||||
public function deleteMedia(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'id' => 'required|integer|min:1|exists:media,id'
|
||||
]);
|
||||
|
||||
$media = Media::whereNull('status_id')
|
||||
->whereUserId(Auth::id())
|
||||
->findOrFail($request->input('id'));
|
||||
|
||||
Storage::delete($media->media_path);
|
||||
Storage::delete($media->thumbnail_path);
|
||||
|
||||
$media->forceDelete();
|
||||
|
||||
return response()->json([
|
||||
'msg' => 'Successfully deleted',
|
||||
'code' => 200
|
||||
]);
|
||||
}
|
||||
|
||||
public function verifyCredentials(Request $request)
|
||||
{
|
||||
$profile = Auth::user()->profile;
|
||||
|
|
Loading…
Reference in a new issue