forked from mirror/pixelfed
Update BaseApiController
This commit is contained in:
parent
16336bf5bc
commit
2348621510
|
@ -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 New Issue