public static function deleteVideosByUser($userId) { $finalists = Finalists::where('category', 'videos')->get(); foreach ($finalists as $finalist) { self::where('videosId', '=', $finalist->idCategory)->where('usersId', '=', $userId)->delete(); } return self::where('usersId', $userId)->delete(); }
public static function deletePhotosByUser($userId) { $directory = "assets/images/_upload/fotos/" . $userId; File::deleteDirectory($directory); $finalists = Finalists::where('category', 'fotos')->get(); foreach ($finalists as $finalist) { self::where('photosId', '=', $finalist->idCategory)->where('usersId', '=', $userId)->delete(); } return self::where('usersId', $userId)->delete(); }