Update BaseApiController

This commit is contained in:
Daniel Supernault 2019-02-27 21:11:56 -07:00
parent 16336bf5bc
commit 2348621510
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -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;