/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $user = \App\Models\User::all(); if (count($user) > 1) { if (!empty($id)) { // Verificando se existe imagem $imagem = \App\Models\Details::where("detail_perfil_id", $id)->where("detail_avatar", "!=", '')->first(); if (isset($imagem) && $imagem->detail_avatar != '' && \File::exists('uploads/' . $imagem->detail_avatar)) { \File::delete('uploads/' . $imagem->detail_avatar); } $delete = \App\Models\User::where("id", $id)->delete(); if ($delete) { $details = \App\Models\Details::where("detail_perfil_id", $id)->delete(); if ($details) { return 'sucesso'; } } } } else { return 'ultimousuario'; } }